/* =========================================================
   Bostametria — identidade "instrumento de medição"
   ========================================================= */
:root {
  --ink: #16405f;          /* tinta: estrutura, títulos */
  --ink-2: #3c5d77;
  --muted: #6b8196;
  --line: #d9e2e9;
  --line-2: #e8eef2;
  --bg: #f4f7f9;           /* porcelana */
  --card: #ffffff;
  --accent: #22a57c;       /* verde de leitura */
  --accent-ink: #0f6e52;
  --accent-soft: #e3f5ee;
  --lcd: #dcf1e7;          /* visor da balança */
  --lcd-edge: #b9dfcd;
  --lcd-ink: #0d4b3a;
  --sample: #7a4a26;       /* amostra */
  --warn: #b7791f;
  --danger: #c2413b;
  --danger-soft: #fbeceb;
  --faf-hard: #8a5a33;
  --faf-ideal: #22a57c;
  --faf-soft: #c99a2e;
  --faf-liquid: #c2653b;
  --shadow: 0 1px 2px rgb(22 64 95 / .06), 0 6px 20px -8px rgb(22 64 95 / .18);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --f-display: 'Sora', system-ui, sans-serif;
  --f-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'Chivo Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e4eef5; --ink-2: #b9cad8; --muted: #8aa1b4; --line: #26404f; --line-2: #1d3443;
    --bg: #0b1822; --card: #122533; --accent: #3cc497; --accent-ink: #7fe0bd; --accent-soft: #143a31;
    --lcd: #0f2e27; --lcd-edge: #1e4a3e; --lcd-ink: #8ff0c9; --sample: #c08a5c;
    --danger: #ef7a73; --danger-soft: #3a1d1c;
    --faf-hard: #c08a5c; --faf-ideal: #3cc497; --faf-soft: #e0b64e; --faf-liquid: #e4855c;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 24px -10px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e4eef5; --ink-2: #b9cad8; --muted: #8aa1b4; --line: #26404f; --line-2: #1d3443;
  --bg: #0b1822; --card: #122533; --accent: #3cc497; --accent-ink: #7fe0bd; --accent-soft: #143a31;
  --lcd: #0f2e27; --lcd-edge: #1e4a3e; --lcd-ink: #8ff0c9; --sample: #c08a5c;
  --danger: #ef7a73; --danger-soft: #3a1d1c;
  --faf-hard: #c08a5c; --faf-ideal: #3cc497; --faf-soft: #e0b64e; --faf-liquid: #e4855c;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 24px -10px rgb(0 0 0 / .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--f-body); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain;
}
h1, h2, h3 { font-family: var(--f-display); letter-spacing: -.02em; line-height: 1.15; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Estrutura ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 10px; background: #fff; object-fit: contain; box-shadow: 0 0 0 1px var(--line); }
.brand b { font: 800 1.12rem/1 var(--f-display); letter-spacing: -.03em; }
.brand b span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 4px 12px 4px 4px; font-size: .82rem; font-weight: 600; cursor: pointer; max-width: 50vw;
}
.user-chip .av {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ink); color: var(--bg); font: 700 .78rem var(--f-display);
}
.user-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main.view {
  flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: 8px 16px calc(var(--nav-h) + var(--safe-b) + 28px);
  animation: viewIn .28s ease both;
}
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 10px 0 16px; }
.eyebrow { font: 600 .72rem/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* ---------- Navegação inferior ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr); align-items: stretch;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  appearance: none; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--muted);
  font: 600 .72rem/1 var(--f-body); text-decoration: none; position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"]::before {
  content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}
.tab.capture { color: var(--ink); }
.tab.capture .fab {
  width: 56px; height: 56px; margin-top: -22px; border-radius: 18px; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); box-shadow: 0 8px 20px -6px rgb(22 64 95 / .55), 0 0 0 5px var(--bg);
  transition: transform .15s;
}
.tab.capture:active .fab { transform: scale(.94); }
.tab.capture[aria-current="page"] .fab { background: var(--accent); color: #fff; }
.tab.capture[aria-current="page"]::before { display: none; }

@media (min-width: 960px) {
  .app { padding-left: 96px; }
  .tabbar {
    top: 0; right: auto; width: 96px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 84px;
    align-content: center; border-top: 0; border-right: 1px solid var(--line); padding: 0;
  }
  .tab[aria-current="page"]::before { top: 22px; left: 0; width: 3px; height: 40px; border-radius: 0 3px 3px 0; }
  .tab.capture .fab { margin-top: 0; box-shadow: 0 8px 20px -6px rgb(22 64 95 / .5); }
  main.view { max-width: 980px; padding-bottom: 40px; }
}

/* ---------- Componentes base ---------- */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head small { color: var(--muted); font-size: .8rem; }

.btn {
  appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px; font-weight: 700; font-size: 1rem; text-decoration: none;
  background: var(--ink); color: var(--bg); transition: transform .12s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .86rem; border-radius: 11px; }
.btn.icon { width: 44px; min-height: 44px; padding: 0; }
.link-btn { appearance: none; border: 0; background: none; padding: 0; color: var(--accent-ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.field label, .label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--card);
  padding: 12px 14px; font-size: 16px; /* 16px evita zoom no iOS */ transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-unit { position: relative; }
.input-unit .input { padding-right: 48px; font-family: var(--f-mono); font-weight: 700; font-size: 1.15rem; }
.input-unit span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font: 600 .9rem var(--f-mono); pointer-events: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 .field + .field { margin-top: 0; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; flex: none; border: 1.5px solid var(--line); background: var(--card); color: var(--ink-2);
  min-height: 38px; padding: 0 14px; border-radius: 999px; font-weight: 600; font-size: .86rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.tag { display: inline-flex; align-items: center; gap: 5px; font: 600 .72rem/1 var(--f-mono); letter-spacing: .02em; padding: 5px 8px; border-radius: 7px; background: var(--line-2); color: var(--ink-2); }
.tag.ai { background: var(--accent-soft); color: var(--accent-ink); }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); font-size: .9rem; }
.notice svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.notice.warn { background: color-mix(in srgb, var(--warn) 14%, var(--card)); color: color-mix(in srgb, var(--warn) 80%, var(--ink)); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice b { display: block; }

/* ---------- Régua (assinatura) ---------- */
.ruler {
  height: 12px; margin: 4px 0 18px; opacity: .5;
  background:
    repeating-linear-gradient(90deg, var(--ink) 0 1.5px, transparent 1.5px 50px) bottom left / 100% 12px no-repeat,
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 10px) bottom left / 100% 6px no-repeat;
  -webkit-mask-image: linear-gradient(90deg, #000 60%, transparent);
          mask-image: linear-gradient(90deg, #000 60%, transparent);
}

/* ---------- Visor (leituras) ---------- */
.lcd {
  position: relative; background: var(--lcd); border: 1.5px solid var(--lcd-edge); border-radius: 14px;
  color: var(--lcd-ink); padding: 12px 14px; overflow: hidden;
  box-shadow: inset 0 2px 0 rgb(255 255 255 / .35), inset 0 -10px 24px -18px rgb(13 75 58 / .5);
}
.lcd .k { font: 600 .68rem/1.2 var(--f-mono); letter-spacing: .07em; text-transform: uppercase; opacity: .78; }
.lcd .v { font: 700 1.9rem/1.1 var(--f-mono); letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lcd .v small { font-size: .5em; font-weight: 600; margin-left: 3px; letter-spacing: 0; opacity: .8; }
.lcd .sub { font-size: .76rem; margin-top: 2px; opacity: .78; }
.lcd.empty .v { opacity: .35; }

.hero-readout { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: end; padding: 18px; }
.hero-readout .v { font-size: 3rem; }
.hero-readout .side { text-align: right; font: 600 .82rem/1.5 var(--f-mono); }
.hero-readout .side b { font-size: 1.15rem; display: block; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi-group { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.kpi-group > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .9rem; }
.kpi-group > h3 svg { width: 18px; height: 18px; color: var(--accent); }
.kpi-group .lcd + .lcd { margin-top: 8px; }
.kpi-group .lcd .v { font-size: 1.5rem; }
@media (max-width: 360px) { .kpis { grid-template-columns: 1fr; } }
@media (min-width: 960px) { .dash-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; align-items: start; } .dash-grid > * + * { margin-top: 0; } }

/* ---------- Escala F.A.F. (paquímetro) ---------- */
.faf-scale { --pos: 50%; position: relative; padding-top: 34px; }
.faf-bar {
  height: 16px; border-radius: 8px; position: relative;
  background: linear-gradient(90deg, var(--faf-hard) 0%, var(--faf-hard) 22%, var(--faf-ideal) 40%, var(--faf-ideal) 60%, var(--faf-soft) 78%, var(--faf-liquid) 100%);
}
.faf-ticks { display: grid; grid-template-columns: repeat(15, 1fr); margin-top: 4px; }
.faf-ticks span { text-align: center; font: 600 .66rem/1 var(--f-mono); color: var(--muted); position: relative; padding-top: 9px; }
.faf-ticks span::before { content: ''; position: absolute; top: 0; left: 50%; width: 1.5px; height: 6px; background: var(--muted); }
.faf-ticks span:nth-child(odd)::before { height: 8px; background: var(--ink-2); }
.faf-cursor {
  position: absolute; top: 0; left: var(--pos); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  transition: left .5s cubic-bezier(.3,1.4,.5,1);
}
.faf-cursor b { font: 700 .95rem/1 var(--f-mono); background: var(--ink); color: var(--bg); padding: 5px 8px; border-radius: 8px; }
.faf-cursor::after { content: ''; width: 3px; height: 28px; background: var(--ink); border-radius: 2px; margin-top: -2px; box-shadow: 0 0 0 2px var(--card); }
.faf-legend { display: flex; justify-content: space-between; margin-top: 8px; font-size: .76rem; color: var(--muted); font-weight: 600; }
.faf-desc { margin-top: 12px; font-size: .92rem; color: var(--ink-2); display: flex; gap: 10px; align-items: flex-start; }
.faf-desc .dot { width: 12px; height: 12px; border-radius: 4px; flex: none; margin-top: 5px; }
/* slider sobreposto à escala */
.faf-input { position: absolute; inset: 20px 0 auto 0; width: 100%; height: 48px; margin: 0; opacity: 0; cursor: pointer; }
.faf-scale.interactive .faf-cursor b { font-size: 1.1rem; padding: 7px 10px; }

/* ---------- Gráficos ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font: 500 10px var(--f-mono); }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { opacity: .35; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--ink); stroke: var(--card); stroke-width: 2; }
.chart .band { opacity: .1; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 7px 10px; font: 600 .76rem/1.35 var(--f-body); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px));
  box-shadow: var(--shadow);
}
.tooltip b { font-family: var(--f-mono); }
.chart-empty { padding: 26px 8px; text-align: center; color: var(--muted); font-size: .9rem; }
.table-toggle { margin-top: 10px; font-size: .8rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: 8px; }
.data-table th, .data-table td { padding: 6px 4px; border-bottom: 1px solid var(--line-2); text-align: right; font-family: var(--f-mono); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }

/* ---------- Tela de entrada / termo ---------- */
.gate { min-height: 100dvh; display: flex; flex-direction: column; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); max-width: 480px; margin: 0 auto; animation: viewIn .35s ease both; }
.gate-logo { width: min(230px, 62vw); margin: 8px auto 6px; border-radius: 22px; background: #fff; padding: 8px; box-shadow: var(--shadow); }
.gate-tagline { text-align: center; color: var(--muted); font-size: .92rem; margin-bottom: 22px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--line-2); border-radius: 14px; padding: 4px; margin-bottom: 18px; }
.seg button { appearance: none; border: 0; background: none; min-height: 42px; border-radius: 11px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(22 64 95 / .15); }
.form-error { color: var(--danger); font-size: .88rem; font-weight: 600; min-height: 1.3em; margin: 10px 0 4px; }

.consent-doc { counter-reset: sec; }
.consent-doc section { padding: 14px 0; border-top: 1px dashed var(--line); }
.consent-doc section:first-child { border-top: 0; padding-top: 4px; }
.consent-doc h3 { margin-bottom: 4px; }
.consent-doc p { color: var(--ink-2); font-size: .94rem; }
.consent-check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer; margin: 16px 0; font-size: .93rem; font-weight: 500; }
.consent-check input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; margin: 0; }
.consent-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0 calc(8px + var(--safe-b)); background: var(--bg); display: grid; gap: 8px; }
.sticky-actions::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 28px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
.sticky-actions .btn:disabled { opacity: 1; background: var(--line); color: var(--muted); }

/* ---------- Coleta ---------- */
.capture-hero { text-align: center; padding: 26px 18px; }
.viewfinder {
  position: relative; aspect-ratio: 4 / 3.3; border-radius: 22px; margin-bottom: 20px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 55%, var(--card) 0 34%, var(--line-2) 34.5% 45%, var(--card) 45.5%);
  border: 1px solid var(--line-2); overflow: hidden;
}
.viewfinder .bowl { width: 58%; aspect-ratio: .82; border-radius: 50%; border: 3px solid var(--line); background: var(--bg); position: relative; }
.viewfinder .bowl::after { content: ''; position: absolute; inset: 22% 18% 16%; border-radius: 50%; background: color-mix(in srgb, #8fc6e6 26%, var(--bg)); }
.viewfinder .corner { position: absolute; width: 34px; height: 34px; border: 4px solid var(--accent); }
.viewfinder .c1 { top: 16px; left: 16px; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.viewfinder .c2 { top: 16px; right: 16px; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.viewfinder .c3 { bottom: 16px; left: 16px; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.viewfinder .c4 { bottom: 16px; right: 16px; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.viewfinder .scan { position: absolute; left: 12%; right: 12%; height: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: scan 2.8s ease-in-out infinite; opacity: .7; }
@keyframes scan { 0%, 100% { top: 22%; } 50% { top: 78%; } }
.tips { text-align: left; margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.tips li { display: flex; gap: 10px; font-size: .9rem; color: var(--ink-2); }
.tips li svg { width: 20px; height: 20px; color: var(--accent); flex: none; }

.stage { position: relative; border-radius: 18px; overflow: hidden; background: #0b1822; display: flex; justify-content: center; user-select: none; -webkit-user-select: none; }
.stage .frame { position: relative; line-height: 0; }
.stage img { width: auto; max-width: 100%; height: auto; max-height: 52dvh; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.stage .busy {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px;
  background: rgb(11 24 34 / .55); color: #fff; font-weight: 600; backdrop-filter: blur(2px);
}
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3.5px solid rgb(255 255 255 / .25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--line-2); padding: 5px; border-radius: 14px; margin: 10px 0 6px; }
.tools button { appearance: none; border: 0; background: none; border-radius: 10px; min-height: 48px; font-weight: 700; font-size: .82rem; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.1; }
.tools button i { font-style: normal; width: 10px; height: 10px; border-radius: 3px; }
.tools button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(22 64 95 / .15); }
.tool-hint { font-size: .85rem; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; align-items: center; min-height: 38px; }
.readouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.readouts .lcd { padding: 10px; }
.readouts .lcd .v { font-size: 1.3rem; }

.ai-card { display: flex; gap: 12px; align-items: flex-start; }
.ai-card .conf { margin-left: auto; text-align: right; font: 700 1.1rem/1 var(--f-mono); color: var(--accent-ink); }
.ai-card .conf small { display: block; font: 600 .66rem/1.4 var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.success { text-align: center; padding: 34px 18px; }
.success .check { width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 24px; background: var(--accent); color: #fff; display: grid; place-items: center; animation: pop .45s cubic-bezier(.3,1.6,.5,1) both; }
.success .check svg { width: 40px; height: 40px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ---------- Relatório ---------- */
.filters { display: grid; gap: 10px; }
.filters .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 18px 2px 10px; font-size: .86rem; color: var(--muted); font-weight: 600; }
.m-list { display: grid; gap: 10px; }
.m-item {
  appearance: none; width: 100%; text-align: left; cursor: pointer; display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; padding: 10px; box-shadow: var(--shadow); color: inherit;
  transition: transform .12s;
}
.m-item:active { transform: scale(.99); }
.m-item .thumb { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; background: var(--line-2); }
.m-item .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.m-item .when { font-weight: 700; font-size: .93rem; }
.m-item .who { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-item .vals { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font: 700 .9rem/1 var(--f-mono); }
.m-item .vals span small { font-weight: 500; color: var(--muted); margin-left: 2px; font-size: .78em; }
.faf-pill { display: inline-flex; align-items: center; gap: 5px; font: 700 .76rem/1 var(--f-mono); padding: 4px 7px 4px 5px; border-radius: 7px; background: var(--line-2); }
.faf-pill i { width: 9px; height: 9px; border-radius: 3px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state svg { width: 54px; height: 54px; color: var(--line); margin: 0 auto 12px; }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }
.empty-state .btn { margin-top: 16px; }

/* ---------- Folhas (bottom sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(8 20 30 / .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(22px + var(--safe-b)); animation: up .28s cubic-bezier(.2,.9,.3,1) both; overscroll-behavior: contain;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 24px; } }
.menu-list { display: grid; gap: 8px; }
.menu-item {
  appearance: none; width: 100%; border: 1px solid var(--line-2); background: var(--card); border-radius: 16px; padding: 14px;
  display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer; color: inherit; font-weight: 600;
}
.menu-item .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--line-2); color: var(--ink); flex: none; }
.menu-item .ic svg { width: 22px; height: 22px; }
.menu-item.primary .ic { background: var(--accent); color: #fff; }
.menu-item small { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; }
.menu-item .chev { margin-left: auto; color: var(--muted); width: 18px; height: 18px; }
.detail-photo { border-radius: 16px; overflow: hidden; background: var(--line-2); margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .9rem; margin-top: 14px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; text-align: right; font-weight: 600; }
.steps { counter-reset: st; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { counter-increment: st; display: flex; gap: 12px; align-items: flex-start; font-size: .95rem; }
.steps li::before { content: counter(st); width: 28px; height: 28px; border-radius: 9px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font: 700 .85rem var(--f-mono); flex: none; }
.steps svg { width: 18px; height: 18px; vertical-align: -3px; }

.install-banner { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 16px; background: var(--ink); color: var(--bg); margin-bottom: 14px; }
.install-banner img { width: 40px; height: 40px; border-radius: 10px; background: #fff; }
.install-banner p { font-size: .85rem; flex: 1; line-height: 1.3; }
.install-banner p b { display: block; font-size: .95rem; }
.install-banner .btn { background: var(--accent); color: #fff; }
.install-banner .x { appearance: none; border: 0; background: none; color: inherit; opacity: .7; padding: 6px; cursor: pointer; }

.users-list .u { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.users-list .u:first-child { border-top: 0; }
.users-list .u .meta { flex: 1; min-width: 0; }
.users-list .u .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-list .u .meta small { color: var(--muted); font-size: .8rem; }
.users-list select.input { width: auto; min-height: 40px; padding: 6px 10px; font-size: .85rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: .92rem;
  box-shadow: var(--shadow); animation: up .25s ease both; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); color: #fff; }

.skeleton { background: linear-gradient(90deg, var(--line-2), var(--card), var(--line-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .tabbar, .topbar, .no-print { display: none !important; }
  main.view { padding: 0; max-width: none; }
  .card, .m-item { box-shadow: none; break-inside: avoid; }
}

/* ---------- Guia de instalação ---------- */
.guide-intro { color: var(--ink-2); font-size: .93rem; margin-bottom: 14px; }
.guide-note { color: var(--muted); font-size: .82rem; margin-top: 14px; }
.steps li span { padding-top: 3px; }

/* ---------- Proteções contra estouro horizontal no celular ---------- */
html, body { overflow-x: clip; }
.input { min-width: 0; max-width: 100%; }
.grid-2 > *, .filters .row > *, .readouts > *, .kpis > * { min-width: 0; }
input[type="date"].input, input[type="datetime-local"].input {
  -webkit-appearance: none; appearance: none; display: block; text-align: left;
}
input[type="date"].input::-webkit-date-and-time-value,
input[type="datetime-local"].input::-webkit-date-and-time-value { text-align: left; }
select.input { -webkit-appearance: none; appearance: none; padding-right: 40px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b8196' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 12px center / 18px no-repeat; }

/* ---------- Pessoas, amigos e análise da IA ---------- */
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip.add { border-style: dashed; color: var(--accent-ink); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--danger); color: #fff; font: 700 .72rem/1 var(--f-body); vertical-align: 1px; }
.av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--line-2); color: var(--ink); font: 700 .85rem var(--f-display); }
.av.me { background: var(--ink); color: var(--bg); }
.person-row, .friend-row { display: flex; align-items: center; gap: 12px; }
.person-row { padding: 14px; }
.friend-row { padding: 10px 0; border-top: 1px solid var(--line-2); }
.friend-row:first-of-type { border-top: 0; }
.person-row .meta, .friend-row .meta { flex: 1; min-width: 0; }
.person-row .meta b, .friend-row .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-row .meta small, .friend-row .meta small { display: block; color: var(--muted); font-size: .8rem; }
.person-row .acts, .cmp-row .acts { display: flex; gap: 6px; flex: none; }
.btn.icon.sm { width: 38px; min-height: 38px; }

.cmp-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.cmp-row:first-child { border-top: 0; padding-top: 2px; }
.cmp-row .rank { width: 18px; flex: none; text-align: center; font: 700 .85rem var(--f-mono); color: var(--muted); }
.cmp-row .meta { flex: 1; min-width: 0; }
.cmp-row .nm { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cmp-row .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-row .cnt { font: 700 .8rem var(--f-mono); color: var(--ink-2); flex: none; }
.cmp-row .freq { height: 6px; border-radius: 3px; background: var(--line-2); margin: 6px 0 7px; overflow: hidden; }
.cmp-row .freq i { display: block; height: 100%; border-radius: 3px; background: var(--ink-2); }
.cmp-row.me .freq i { background: var(--accent); }
.cmp-row .vals { display: flex; flex-wrap: wrap; gap: 4px 12px; font: 700 .85rem/1.2 var(--f-mono); align-items: center; }
.cmp-row .vals small { font-weight: 500; color: var(--muted); margin-left: 3px; font-size: .78em; }
.privacy-note { color: var(--muted); font-size: .8rem; margin: 14px 2px 0; }

.conf-row { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--ink-2); margin-bottom: 12px; }
.conf-row b { font-family: var(--f-mono); color: var(--accent-ink); }
.conf-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.conf-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.ai-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ai-table th, .ai-table td { padding: 8px 4px; border-bottom: 1px solid var(--line-2); text-align: right; }
.ai-table thead th { font: 600 .68rem var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ai-table th:first-child { text-align: left; font-weight: 600; color: var(--ink-2); }
.ai-table td { font: 700 .92rem var(--f-mono); }
.ai-table td small { font-weight: 500; color: var(--muted); }
.ai-table tr.changed td:last-child { color: var(--accent-ink); }
.ai-table .adj { display: block; font: 600 .66rem var(--f-body); color: var(--warn); }
.ai-line { font-size: .88rem; color: var(--ink-2); margin-top: 10px; }
.ai-line span { display: block; font: 600 .68rem var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.ai-line code { font-family: var(--f-mono); font-size: .85rem; }
.cmp-row { align-items: flex-start; }
.cmp-row .rank { padding-top: 11px; }
.cmp-row .acts { margin-top: 10px; flex-wrap: wrap; }
.form-error:empty { min-height: 0; margin: 0; }
#invite .form-error:not(:empty) { margin-top: 10px; }

/* ---------- Câmera do app ---------- */
.cam { position: fixed; inset: 0; z-index: 80; background: #000; color: #fff; overflow: hidden; animation: fade .2s ease both; }
.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-video.mirror { transform: scaleX(-1); }
.cam-guide { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); width: min(78vw, 58vh); aspect-ratio: .82; pointer-events: none; }
.cam-guide .corner { position: absolute; width: 38px; height: 38px; border: 4px solid var(--accent); filter: drop-shadow(0 0 3px rgb(0 0 0 / .5)); }
.cam-guide .c1 { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.cam-guide .c2 { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.cam-guide .c3 { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.cam-guide .c4 { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.cam-bowl { position: absolute; inset: 7%; border-radius: 50%; border: 2px dashed rgb(255 255 255 / .6); box-shadow: 0 0 0 9999px rgb(0 0 0 / .28); }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: calc(12px + var(--safe-t)) 14px 12px; background: linear-gradient(rgb(0 0 0 / .55), transparent); }
.cam-tip { flex: 1; text-align: center; font-size: .9rem; text-shadow: 0 1px 3px rgb(0 0 0 / .6); }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 22px 24px calc(26px + var(--safe-b)); background: linear-gradient(transparent, rgb(0 0 0 / .6)); }
.cam-side { display: flex; justify-content: center; }
.cam-btn { appearance: none; width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgb(255 255 255 / .16); color: #fff; cursor: pointer; backdrop-filter: blur(6px); flex: none; }
.cam-btn svg { width: 24px; height: 24px; }
.cam-btn.on { background: #ffd35c; color: #1a1a1a; }
.cam-shutter { appearance: none; width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; cursor: pointer; }
.cam-shutter i { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .12s, background .12s; }
.cam-shutter:active i { transform: scale(.88); background: var(--accent); }
.cam-shutter:disabled { opacity: .5; }
.cam-status { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px; font-weight: 600; background: #000; }
.cam-status[hidden] { display: none; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
