@font-face { font-family: "Archivo"; font-weight: 400; font-display: swap; src: url("fonts/archivo-400.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 600; font-display: swap; src: url("fonts/archivo-600.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap; src: url("fonts/archivo-700.woff2") format("woff2"); }

/* Identidade visual São Francisco Casa & Construção
   01 Azul #031354 · 02 Vermelho #da2535 · 03 Azul claro #0486d9 · 04 Amarelo #d9d33a */
:root {
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #eeede8;
  --border: #dcdad3;
  --text: #1b1b1a;
  --text-2: #52514e;
  --text-3: #75746f;
  --marca-azul: #031354;
  --marca-vermelho: #da2535;
  --marca-azul-claro: #0486d9;
  --marca-amarelo: #d9d33a;
  --brand: #031354;
  --brand-btn: #031354;
  --brand-ink: #ffffff;
  --accent: #da2535;
  --serie: #0486d9;
  --good: #0ca30c;
  --warn: #c98500;
  --bad: #d03b3b;
  --good-bg: #e6f5e6;
  --warn-bg: #fdf3dc;
  --bad-bg: #fbe8e8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #383835;
    --text: #f4f3ef; --text-2: #c3c2b7; --text-3: #9a998f;
    --brand: #7fb6ec; --brand-btn: #0486d9; --serie: #2f9be3;
    --good-bg: #16301a; --warn-bg: #33290f; --bad-bg: #3a1c1c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #383835;
  --text: #f4f3ef; --text-2: #c3c2b7; --text-3: #9a998f;
  --brand: #7fb6ec; --brand-btn: #0486d9; --serie: #2f9be3;
  --good-bg: #16301a; --warn-bg: #33290f; --bad-bg: #3a1c1c;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.carregando { padding: 48px 16px; text-align: center; color: var(--text-2); }

/* Topo */
.topo {
  position: sticky; top: 0; z-index: 10;
  background: var(--marca-azul); color: #fff; border-bottom: 4px solid var(--marca-vermelho);
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topo h1 { margin: 0; line-height: 0; }
.topo h1 img { height: 38px; width: auto; }
.topo .quem { font-size: 13px; opacity: .85; text-align: right; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 20px 0 8px; }
.sub { color: var(--text-2); font-size: 14px; margin: -6px 0 14px; }
.muted { color: var(--text-3); font-size: 13px; }

/* Navegação inferior */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav a {
  flex: 1; text-align: center; text-decoration: none; color: var(--text-2);
  font-size: 12px; padding: 6px 2px; border-radius: 10px; position: relative;
}
.nav a .ic { display: block; font-size: 20px; line-height: 1.2; }
.nav a.ativo { color: var(--brand); font-weight: 650; background: var(--surface-2); }
.badge {
  position: absolute; top: 0; right: calc(50% - 22px);
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 5px;
}

/* Cartões */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.linha { display: flex; align-items: center; gap: 12px; }
.linha .grow { flex: 1; min-width: 0; }
.amb-nome { font-weight: 600; }
.thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; cursor: zoom-in; }
.thumb.vazio { display: grid; place-items: center; color: var(--text-3); font-size: 26px; cursor: default; }

/* Status (sempre ícone + texto, nunca só cor) */
.st { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.st.ok { background: var(--good-bg); color: var(--good); }
.st.pend { background: var(--warn-bg); color: var(--warn); }
.st.ruim { background: var(--bad-bg); color: var(--bad); }
.st.neutro { background: var(--surface-2); color: var(--text-2); }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; min-height: 44px;
  text-decoration: none;
}
.btn.prim { background: var(--brand-btn); border-color: var(--brand-btn); color: #fff; }
.btn.destaque { background: var(--marca-vermelho); border-color: var(--marca-vermelho); color: #fff; }
.btn.bloco { width: 100%; }
.btn.peq { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--text-2); min-height: 40px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.sim-nao button.on.sim { background: var(--good-bg); color: var(--good); }
.seg.sim-nao button.on.nao { background: var(--bad-bg); color: var(--bad); }

/* Formulários */
label.campo { display: block; margin: 12px 0; font-size: 14px; color: var(--text-2); }
label.campo input, label.campo select, label.campo textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; font-size: 15px; }
.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; }
.caixa { background: var(--surface-2); border-radius: 10px; padding: 4px 12px; }

/* Login */
.tela-login { min-height: 100vh; background: var(--marca-azul); color: #fff; margin-bottom: calc(-72px - env(safe-area-inset-bottom)); }
.tela-login::before { content: ""; display: block; height: 6px; background: var(--marca-vermelho); }
.login { max-width: 420px; margin: 0 auto; padding: 28px 16px 40px; }
.login .sub { color: rgba(255,255,255,.8); }
.login .btn { background: #fff; color: var(--marca-azul); border-color: transparent; }
.login .nomes small { color: #5b6380; }
.login .marca { text-align: center; margin-bottom: 20px; }
.login .marca img { width: 220px; height: auto; margin: 0 auto 8px; }
.nomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nomes button { display: block; text-align: left; min-width: 0; overflow-wrap: anywhere; }
.nomes small { display: block; color: var(--text-3); font-weight: 400; font-size: 12px; }
.pin-input { font: 600 28px ui-monospace, monospace !important; letter-spacing: 8px; text-align: center; }

/* Painel */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.tile .rot { font-size: 13px; color: var(--text-2); }
.tile .num { font-size: 32px; font-weight: 700; line-height: 1.1; margin: 4px 0; font-variant-numeric: tabular-nums; }
.tile .det { font-size: 13px; color: var(--text-3); }
.grafico { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.grafico .col { flex: 1; max-width: 32px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.grafico .bar { background: var(--serie); border-radius: 4px 4px 0 0; min-height: 2px; }
.grafico .bar.parcial { background: repeating-linear-gradient(45deg, var(--serie) 0 4px, transparent 4px 7px); border: 1px solid var(--serie); }
.grafico .col:hover .bar, .grafico .col:focus .bar { filter: brightness(1.15); }
.grafico .meta { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--text-3); pointer-events: none; }
.eixo { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }
.dica {
  position: fixed; z-index: 30; pointer-events: none; background: var(--text); color: var(--bg);
  font-size: 13px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; display: none;
}
.rank-linha { display: grid; grid-template-columns: 1fr 110px 48px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--surface-2); font-size: 14px; }
.rank-linha .trilho { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.rank-linha .trilho span { display: block; height: 100%; background: var(--serie); border-radius: 4px; }
.rank-linha .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
table.tab { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tab th, table.tab td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--surface-2); }
table.tab td.n, table.tab th.n { text-align: right; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; }

/* Avaliação */
.foto-grande { width: 100%; max-height: 60vh; object-fit: contain; background: #000; border-radius: 10px; cursor: zoom-in; }
.pontos-vivo { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.aviso { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.aviso.warn { background: var(--warn-bg); }
.aviso.bad { background: var(--bad-bg); }
.aviso.good { background: var(--good-bg); }

/* Modal / folha */
.fundo { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.folha {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) { .fundo { align-items: center; } .folha { border-radius: 16px; } }
.folha h3 { margin-top: 0; }
.zoom { position: fixed; inset: 0; background: #000; z-index: 50; display: grid; place-items: center; }
.zoom img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.zoom button { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 22px; }
.preview { width: 100%; max-height: 40vh; object-fit: contain; border-radius: 10px; background: var(--surface-2); margin: 8px 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60;
  font-size: 14px; display: none; max-width: calc(100% - 32px);
}
#toast.erro { background: var(--bad); color: #fff; }
.offline { background: var(--warn-bg); color: var(--text); text-align: center; font-size: 13px; padding: 6px; }
