/* Compasso — Design System (fork Consolida, simplificado) */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --surface-3: #e5e5ea;
  --separator: rgba(60, 60, 67, 0.12);
  --label: #1c1c1e;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --tint: #0A84FF;
  --tint-15: rgba(10, 132, 255, 0.15);
  --tint-30: rgba(10, 132, 255, 0.30);
  --tint-press: #006bd6;
  --success: #34C759;
  --success-15: rgba(52, 199, 89, 0.15);
  --warning: #FF9F0A;
  --warning-15: rgba(255, 159, 10, 0.18);
  --danger: #FF3B30;
  --danger-15: rgba(255, 59, 48, 0.15);
  --indigo: #5856D6;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-2xl: 22px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.04);
  --shadow-2: 0 4px 12px rgba(0,0,0,.06);
  --ring: 0 0 0 4px var(--tint-30);
  --bottom-nav-h: 64px;
  --topbar-h: 56px;
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --fs-caption: 12px;
  --fs-footnote: 13px;
  --fs-subhead: 15px;
  --fs-callout: 16px;
  --fs-body: 17px;
  --fs-title-3: clamp(18px, 1vw + 14px, 20px);
  --fs-title-2: clamp(19px, 1.5vw + 12px, 22px);
  --fs-large: clamp(26px, 3vw + 16px, 34px);
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --separator: rgba(84, 84, 88, 0.4);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--tint); text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-md); }

.skip-link {
  position: absolute; left: -9999px; top: auto;
  padding: var(--sp-2) var(--sp-4); background: var(--tint); color: #fff; z-index: 100;
}
.skip-link:focus { left: var(--sp-4); top: var(--sp-4); }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  padding-top: calc(var(--sp-2) + var(--sa-top));
  min-height: calc(var(--topbar-h) + var(--sa-top));
  background: var(--surface);
  border-bottom: 1px solid var(--separator);
}

.brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-weight: 600; font-size: var(--fs-title-3); color: var(--label);
}
.brand-logo { width: 28px; height: 28px; color: var(--tint); }
.crumb { flex: 1; min-width: 0; }
.crumb-title { font-size: var(--fs-callout); font-weight: 600; }
.crumb-subtitle { font-size: var(--fs-caption); color: var(--label-2); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--sp-4) + var(--bottom-nav-h) + var(--sa-bottom));
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 1024px) {
  .content { padding-bottom: calc(var(--sp-6) + var(--sa-bottom)); }
  .bottom-nav { display: none; }
  .desktop-nav {
    display: flex;
    gap: var(--sp-1);
    margin-left: auto;
  }
}

@media (max-width: 1023px) {
  .desktop-nav { display: none; }
}

.desktop-nav button {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-lg);
  font-size: var(--fs-subhead);
  font-weight: 500;
  color: var(--label-2);
}
.desktop-nav button.active { background: var(--tint-15); color: var(--tint); }

.view { display: none; animation: fadeIn 280ms ease; }
.view.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--separator);
  height: calc(var(--bottom-nav-h) + var(--sa-bottom));
  padding-bottom: var(--sa-bottom);
}
.bottom-nav button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--label-2); font-size: 11px; font-weight: 500;
  min-height: 44px; position: relative;
}
.bottom-nav button.active { color: var(--tint); }
.bottom-nav button.active::before {
  content: ""; position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 0 0 4px 4px; background: var(--tint);
}
.bottom-nav .ico { width: 22px; height: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg);
  font-size: var(--fs-callout); font-weight: 600; min-height: 44px;
  background: var(--surface-2); color: var(--label);
  transition: transform 120ms ease, background 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--tint); color: #fff; }
.btn.primary:hover { background: var(--tint-press); }
.btn.tinted { background: var(--tint-15); color: var(--tint); }
.btn.ghost { background: transparent; color: var(--tint); }
.btn.outline { background: transparent; border: 1px solid var(--separator); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-subhead); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-2xl);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-1);
}
.card-header { margin-bottom: var(--sp-3); }
.card-title { font-size: var(--fs-title-3); font-weight: 600; margin: 0 0 var(--sp-1); }
.card-desc { font-size: var(--fs-subhead); color: var(--label-2); margin: 0; }

.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.form-row { display: flex; flex-direction: column; gap: var(--sp-2); }
.form-label { font-size: var(--fs-subhead); font-weight: 500; }
.form-help { font-size: var(--fs-caption); color: var(--label-3); }
.form-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }

.input, .select, textarea.input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--separator);
  border-radius: var(--r-lg);
  background: var(--surface);
  min-height: 44px;
}
textarea.input { min-height: 88px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--tint);
  box-shadow: var(--ring);
  outline: none;
}

.range-row {
  display: flex; align-items: center; gap: var(--sp-3);
}
.range-row input[type="range"] { flex: 1; accent-color: var(--tint); }
.range-val {
  min-width: 36px; text-align: center; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: flex; background: var(--surface-2); border-radius: var(--r-lg); padding: 3px;
}
.segmented button {
  flex: 1; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  font-size: var(--fs-footnote); font-weight: 500; color: var(--label-2);
}
.segmented button.active { background: var(--surface); color: var(--tint); box-shadow: var(--shadow-1); }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: var(--fs-caption); font-weight: 600;
}
.status-pill.done { background: var(--success-15); color: var(--success); }
.status-pill.missing { background: var(--warning-15); color: var(--warning); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-xl);
  padding: var(--sp-3) var(--sp-4);
}
.kpi-label { font-size: var(--fs-caption); color: var(--label-2); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: var(--fs-title-2); font-weight: 700; margin-top: 4px; }

.bar-chart {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-4); background: var(--surface);
  border: 1px solid var(--separator); border-radius: var(--r-2xl);
}
.bar-row {
  display: grid; grid-template-columns: 72px 1fr 40px; gap: var(--sp-2); align-items: center;
  font-size: var(--fs-footnote);
}
.bar-track { background: var(--surface-2); height: 8px; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--tint), var(--indigo)); border-radius: inherit; }
.bar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.history-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.history-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--separator);
  border-radius: var(--r-xl); cursor: pointer;
  transition: background 150ms ease;
}
.history-item:hover { background: var(--surface-2); }
.history-item .hi-date { font-weight: 600; min-width: 88px; }
.history-item .hi-metrics { flex: 1; display: flex; gap: var(--sp-3); font-size: var(--fs-footnote); color: var(--label-2); flex-wrap: wrap; }
.history-item .hi-badge { font-size: var(--fs-caption); color: var(--label-3); }

.report-preview {
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--fs-footnote);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

.read-mode {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  padding: var(--sp-6) var(--sp-4);
  padding-top: calc(var(--sp-6) + var(--sa-top));
  overflow-y: auto;
  font-size: 20px;
  line-height: 1.6;
}
.read-mode .read-close {
  position: fixed; top: calc(var(--sp-3) + var(--sa-top)); right: var(--sp-3);
  z-index: 51;
}

.lock-screen, .onboarding-screen {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6) var(--sp-4);
}
.lock-screen[hidden], .onboarding-screen[hidden] { display: none !important; }
.lock-card, .onboarding-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-2);
}
.lock-card h1, .onboarding-card h1 {
  font-size: var(--fs-large); margin: 0 0 var(--sp-2); text-align: center;
}
.lock-card p, .onboarding-card p { color: var(--label-2); text-align: center; margin: 0 0 var(--sp-4); }

.pin-dots {
  display: flex; justify-content: center; gap: var(--sp-3); margin: var(--sp-4) 0;
}
.pin-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--separator);
}
.pin-dot.filled { background: var(--tint); border-color: var(--tint); }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2);
  max-width: 280px; margin: 0 auto;
}
.pin-pad button {
  min-height: 52px; border-radius: var(--r-xl);
  background: var(--surface-2); font-size: 22px; font-weight: 500;
}
.pin-pad button:active { background: var(--surface-3); }
.pin-pad button.pin-ok {
  background: var(--tint);
  color: #fff;
  font-size: var(--fs-subhead);
  font-weight: 600;
}

.onboarding-steps {
  display: flex; justify-content: center; gap: var(--sp-2); margin-bottom: var(--sp-4);
}
.onboarding-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); }
.onboarding-dot.active { background: var(--tint); }

.toast-host {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-nav-h) + var(--sa-bottom) + var(--sp-4));
  z-index: 90; display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none; width: min(420px, calc(100% - var(--sp-8)));
}
@media (min-width: 1024px) {
  .toast-host { bottom: calc(var(--sa-bottom) + var(--sp-4)); }
}
.toast {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-subhead);
  pointer-events: auto;
  animation: toastIn 280ms ease;
}
.toast.good { border-left: 3px solid var(--success); }
.toast.bad { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--tint); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.4);
  display: none; align-items: flex-end; justify-content: center;
  padding: var(--sp-4);
}
.modal-backdrop.open { display: flex; }
@media (min-width: 720px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-2xl);
  padding: var(--sp-5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.modal-title { font-size: var(--fs-title-3); font-weight: 600; margin: 0; }

.row { display: flex; align-items: center; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; gap: var(--sp-3); }
.spacer { flex: 1; }
.muted { color: var(--label-2); }
.muted-3 { color: var(--label-3); }
.center { text-align: center; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--separator);
}
.toggle-row:last-child { border-bottom: 0; }

.switch {
  width: 51px; height: 31px; border-radius: 999px;
  background: var(--surface-3); position: relative;
  transition: background 200ms ease;
}
.switch.on { background: var(--success); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform 200ms ease;
}
.switch.on::after { transform: translateX(20px); }

.star-rating {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
}
.star-btn {
  font-size: 28px;
  line-height: 1;
  color: var(--surface-3);
  padding: 2px;
  transition: color 150ms ease, transform 120ms ease;
}
.star-btn.on { color: var(--warning); }
.star-btn:active { transform: scale(0.92); }
.star-caption {
  margin-left: var(--sp-2);
  font-size: var(--fs-subhead);
  color: var(--label-2);
  font-weight: 600;
}

.meal-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
}
.meal-check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--separator);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: var(--fs-subhead);
  cursor: pointer;
}
.meal-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--tint);
}

.conflict-banner {
  background: var(--warning-15);
  border: 1px solid var(--warning);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-subhead);
  margin-bottom: var(--sp-3);
}

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

@media print {
  .topbar, .bottom-nav, .desktop-nav, .form-actions, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  .report-preview { max-height: none; border: none; background: #fff; }
}

/* Páginas legais / estáticas */
.legal-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.legal-header {
  padding: var(--sp-4) var(--sp-5);
  padding-top: calc(var(--sp-4) + var(--sa-top));
  border-bottom: 1px solid var(--separator);
  background: var(--surface);
}

.legal-content {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5) calc(var(--sp-8) + var(--sa-bottom));
}

.legal-content h1 {
  font-size: var(--fs-title-2);
  margin: 0 0 var(--sp-2);
}

.legal-content h2 {
  font-size: var(--fs-title-3);
  margin: var(--sp-6) 0 var(--sp-3);
}

.legal-content p, .legal-content li {
  color: var(--label);
  line-height: 1.55;
}

.legal-content ul, .legal-content ol {
  padding-left: 1.25rem;
}

.legal-updated, .legal-lead {
  color: var(--label-2);
  font-size: var(--fs-subhead);
}

.legal-alert {
  background: var(--warning-15);
  border: 1px solid var(--warning);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  margin-top: var(--sp-8);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--separator);
  font-size: var(--fs-subhead);
}

.legal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.settings-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: var(--fs-subhead);
}

.settings-links a {
  padding: var(--sp-2) 0;
}

.disclaimer-box {
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  font-size: var(--fs-footnote);
  color: var(--label-2);
  margin-top: var(--sp-4);
  line-height: 1.5;
}

.disclaimer-box strong {
  color: var(--label);
}

