/* ============================================================
   FOI HOJE? — identidade visual
   Paleta: teal #3F6162 · ink #24393A · blush #FBF5F1
           terracota #B5713F · névoa #E4EDE9 · bordô #97402F
   Tipos:  Fraunces (títulos) · Sora (interface)
   ============================================================ */

:root {
  --teal: #3F6162;
  --teal-deep: #2E4A4B;
  --ink: #24393A;
  --blush: #FBF5F1;
  --terra: #B5713F;
  --terra-deep: #96591F;
  --mist: #E4EDE9;
  --mist-deep: #CBDCD5;
  --bordo: #97402F;
  --white: #FFFFFF;
  --shadow: 0 2px 10px rgba(36, 57, 58, 0.08);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Sora", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--blush);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
}

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 18px 32px;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
h2 { font-size: 1.7rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; color: var(--teal-deep); margin-bottom: 10px; }

.page-head { margin-bottom: 20px; }
.page-head p { margin: 6px 0 0; color: #5C6F6D; font-size: 0.92rem; }
.page-head.compact { margin: 10px 0 14px; }

.stack > * + * { margin-top: 16px; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

/* ---------- Botões ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  padding: 13px 20px;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--terra); color: var(--white); }
.btn-primary:hover { background: var(--terra-deep); }
.btn-secondary { background: var(--teal); color: var(--white); }
.btn-secondary:hover { background: var(--teal-deep); }
.btn-ghost { background: transparent; color: var(--teal-deep); }
.btn-ghost:hover { background: var(--mist); }
.btn-block { display: block; width: 100%; }
.btn-big { padding: 17px 20px; font-size: 1.08rem; }
.btn[disabled] { opacity: 0.55; cursor: wait; }

.linklike {
  background: none; border: none; padding: 4px;
  color: var(--teal); font-family: var(--font-ui);
  font-size: 0.92rem; font-weight: 600;
  text-decoration: underline; cursor: pointer;
}
.other-day { text-align: center; margin: 14px 0 0; }

/* ---------- Formulários ---------- */
.field { display: block; margin-bottom: 4px; }
.field > span {
  display: block; font-weight: 600; font-size: 0.95rem;
  margin-bottom: 8px; color: var(--teal-deep);
}
.field em { font-weight: 400; color: #7A8A88; font-style: normal; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--mist-deep);
  border-radius: 12px;
  padding: 12px 14px;
}
input:focus, textarea:focus, .chip:focus-visible, .btn:focus-visible,
.tab:focus-visible, .linklike:focus-visible, input[type="range"]:focus-visible {
  outline: 3px solid rgba(181, 113, 63, 0.45);
  outline-offset: 1px;
}
textarea { resize: vertical; }

.form-error { color: var(--bordo); font-size: 0.9rem; min-height: 1.2em; margin: 8px 0; }
.save-status { color: var(--teal); font-size: 0.9rem; text-align: center; min-height: 1.2em; margin: 10px 0 0; }
.fine-print { font-size: 0.8rem; color: #7A8A88; margin-top: 8px; }
.fine-print.center { text-align: center; }

/* ---------- Chips ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--teal-deep);
  background: var(--mist);
  border: 1.5px solid transparent;
  border-radius: 999px;
  padding: 9px 15px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.chip:hover { background: var(--mist-deep); }
.chip.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal-deep);
}
.chip.small { padding: 6px 12px; font-size: 0.84rem; }
.range-row { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Sliders ---------- */
.slider-wrap { padding: 4px 2px; }
input[type="range"] {
  width: 100%; accent-color: var(--terra); height: 32px;
}
.slider-anchors {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: #7A8A88;
}
.slider-anchors b {
  font-size: 1.25rem; color: var(--terra-deep);
  font-family: var(--font-display); font-variant-numeric: tabular-nums;
}

/* ---------- Consentimento ---------- */
.consent-box {
  background: var(--mist);
  border-radius: var(--radius);
  padding: 14px;
}
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.88rem; margin: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--teal); flex: none; }

/* ---------- Tela de entrada ---------- */
.view-auth {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 32px;
}
.auth-card { width: 100%; max-width: 400px; }
.brand { text-align: center; margin-bottom: 26px; }
.brand-mark {
  width: 74px; height: 74px; margin: 0 auto 14px;
  background: var(--teal); color: var(--blush);
  border-radius: 26px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 2.6rem; font-weight: 700;
  box-shadow: var(--shadow);
}
.brand-name { font-size: 2.4rem; color: var(--teal-deep); }
.brand-tag { color: #5C6F6D; margin: 8px 0 0; font-size: 0.95rem; }
.auth-tabs {
  display: flex; background: var(--mist); border-radius: 14px;
  padding: 4px; margin-bottom: 18px;
}
.auth-tab {
  flex: 1; border: none; background: transparent;
  font-family: var(--font-ui); font-weight: 600; font-size: 0.95rem;
  color: var(--teal-deep); padding: 10px; border-radius: 11px; cursor: pointer;
}
.auth-tab.active { background: var(--white); box-shadow: var(--shadow); }
.auth-foot { text-align: center; font-size: 0.78rem; color: #8A9A98; margin-top: 26px; }

/* ---------- Hoje ---------- */
.hoje-head { margin-bottom: 18px; }
.hoje-data { color: var(--terra-deep); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 4px; }
.hoje-titulo { font-size: 2.3rem; color: var(--teal-deep); }
.hoje-streak { color: #5C6F6D; font-size: 0.92rem; margin: 6px 0 0; }

.done-card { border: 2px solid var(--mist-deep); }
.done-check {
  font-family: var(--font-display); font-size: 1.25rem;
  color: var(--teal); font-weight: 600; margin: 0 0 12px;
}
.done-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
  margin-bottom: 14px;
}
.done-grid .item span { display: block; font-size: 0.75rem; color: #7A8A88; }
.done-grid .item b { font-size: 1rem; }

.nudge { background: #FDF0E3; border: 1.5px solid #EDD6BC; }
.nudge p { margin: 0 0 12px; font-size: 0.92rem; }

/* ---------- Check-in passo a passo ---------- */
.progress-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.progress-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mist-deep); transition: background 0.2s, width 0.2s;
}
.progress-dots i.on { background: var(--terra); width: 22px; border-radius: 6px; }

.checkin-card { padding: 22px 18px; }
.checkin-q {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 600;
  color: var(--teal-deep); margin: 0 0 4px;
}
.checkin-hint { color: #7A8A88; font-size: 0.86rem; margin: 0 0 18px; }
.checkin-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; }
.checkin-nav .btn { flex: 1; }

/* contador de evacuações */
.counter { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 10px 0; }
.counter button {
  width: 62px; height: 62px; border-radius: 50%;
  border: none; background: var(--mist); color: var(--teal-deep);
  font-size: 2rem; font-weight: 600; cursor: pointer;
}
.counter button:hover { background: var(--mist-deep); }
.counter output {
  font-family: var(--font-display); font-size: 3.4rem; font-weight: 700;
  color: var(--terra-deep); min-width: 76px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* opções empilhadas (sangue, dor, bem-estar…) */
.opt-list { display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--mist-deep); border-radius: 14px;
  background: var(--white); padding: 13px 14px;
  font-family: var(--font-ui); font-size: 0.98rem; font-weight: 500;
  color: var(--ink); cursor: pointer; text-align: left;
  transition: border-color 0.12s, background 0.12s;
}
.opt:hover { background: var(--mist); }
.opt.active { border-color: var(--teal); background: var(--mist); box-shadow: inset 0 0 0 1.5px var(--teal); }
.opt .emoji { font-size: 1.3rem; flex: none; }

/* Bristol */
.bristol-grid { display: flex; flex-direction: column; gap: 9px; }
.bristol {
  display: flex; align-items: center; gap: 14px;
  border: 1.5px solid var(--mist-deep); border-radius: 14px;
  background: var(--white); padding: 10px 14px; cursor: pointer;
  text-align: left; font-family: var(--font-ui);
  transition: border-color 0.12s, background 0.12s;
}
.bristol:hover { background: var(--mist); }
.bristol.active { border-color: var(--teal); background: var(--mist); box-shadow: inset 0 0 0 1.5px var(--teal); }
.bristol svg { flex: none; color: #8A6B4F; }
.bristol .b-label { font-weight: 600; font-size: 0.95rem; }
.bristol .b-desc { display: block; font-weight: 400; font-size: 0.8rem; color: #7A8A88; }

/* ---------- Histórico ---------- */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--white); border-radius: 14px;
  box-shadow: var(--shadow); padding: 13px 14px;
}
.stat b {
  display: block; font-family: var(--font-display);
  font-size: 1.55rem; color: var(--teal-deep);
  font-variant-numeric: tabular-nums;
}
.stat span { font-size: 0.78rem; color: #7A8A88; }
.stat.alert b { color: var(--bordo); }
.chart-card canvas { max-width: 100%; }
.empty { text-align: center; color: #5C6F6D; }

.pro2-line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--mist-deep); font-size: 0.92rem; }
.pro2-line:last-of-type { border-bottom: none; }
.pro2-line b { font-variant-numeric: tabular-nums; }

/* ---------- Painel médico ---------- */
.pat-card {
  display: block; width: 100%; text-align: left;
  background: var(--white); border: none; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; cursor: pointer;
  font-family: var(--font-ui);
}
.pat-card:hover { background: var(--mist); }
.pat-nome { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--teal-deep); }
.pat-sub { font-size: 0.82rem; color: #7A8A88; margin-top: 2px; }
.pat-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.flag {
  font-size: 0.76rem; font-weight: 600; border-radius: 999px;
  padding: 4px 10px; background: var(--mist); color: var(--teal-deep);
}
.flag.warn { background: #F7E3DC; color: var(--bordo); }

/* ---------- Navegação ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center; gap: 2px;
  background: var(--white);
  border-top: 1px solid var(--mist-deep);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}
.tab {
  flex: 1; max-width: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 0.72rem; font-weight: 600;
  color: #8A9A98; padding: 6px 4px; border-radius: 12px;
}
.tab-ico { font-size: 1.25rem; }
.tab.active { color: var(--teal-deep); background: var(--mist); }

/* ---------- Toast e loading ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--white);
  border-radius: 999px; padding: 11px 22px;
  font-size: 0.92rem; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(251, 245, 241, 0.75);
  display: flex; align-items: center; justify-content: center;
}
.loading.hidden { display: none; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--mist-deep); border-top-color: var(--terra);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   RELATÓRIO — só aparece na impressão
   ============================================================ */
.report { display: none; }

@media print {
  body { background: #fff; padding: 0; }
  .view, .tabbar, .toast, .loading { display: none !important; }
  .report {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    color: #1c2b2c; font-size: 11pt; line-height: 1.45;
  }
  .report h1 { font-size: 17pt; margin: 0 0 2pt; color: #2E4A4B; }
  .report .r-sub { font-size: 9.5pt; color: #555; margin: 0 0 14pt; }
  .report h2 { font-size: 12.5pt; color: #2E4A4B; border-bottom: 1.5pt solid #B5713F; padding-bottom: 3pt; margin: 16pt 0 8pt; }
  .report table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  .report th, .report td { border: 0.75pt solid #bbb; padding: 4pt 6pt; text-align: left; }
  .report th { background: #EDF3F0; }
  .report img.r-chart { width: 100%; margin: 6pt 0 10pt; }
  .report .r-kv { display: flex; flex-wrap: wrap; gap: 4pt 22pt; margin: 6pt 0; }
  .report .r-kv div { font-size: 10pt; }
  .report .r-disclaimer {
    margin-top: 18pt; padding-top: 8pt; border-top: 0.75pt solid #bbb;
    font-size: 8.5pt; color: #666;
  }
  .report .r-head { display: flex; justify-content: space-between; align-items: baseline; }
  .report .r-brand { font-size: 10pt; color: #B5713F; font-weight: bold; }
}
