/* Caderninho da Caneta — estilos do app (mobile-first, claro/escuro, impressão) */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #17302d;
  --muted: #5d6d6a;
  --line: #e2ded4;
  --primary: #0f6e66;
  --primary-ink: #ffffff;
  --primary-soft: #dcefec;
  --accent: #d9583b;
  --accent-soft: #fbe3dc;
  --warn: #9a6512;
  --warn-soft: #fbefd6;
  --ok: #2c7a51;
  --zone-never: #cfe9e4;
  --zone-old: #8fcfc4;
  --zone-recent: #f2c46d;
  --zone-last: #ec8a70;
  --body: #e6e1d6;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(23, 48, 45, .06), 0 6px 18px rgba(23, 48, 45, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1615;
    --surface: #162120;
    --surface-2: #1d2b29;
    --ink: #e6efed;
    --muted: #9aaca8;
    --line: #2a3a38;
    --primary: #3cb2a5;
    --primary-ink: #04201c;
    --primary-soft: #173a36;
    --accent: #f08a6e;
    --accent-soft: #3b2520;
    --warn: #f0bf62;
    --warn-soft: #362b17;
    --ok: #6cc596;
    --zone-never: #2e5f57;
    --zone-old: #2f7a6f;
    --zone-recent: #b48a33;
    --zone-last: #c4654b;
    --body: #2a3634;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: var(--ink); min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.plan-badge {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: .8rem; font-weight: 600; cursor: pointer; color: var(--muted); white-space: nowrap; flex: none;
}
.plan-badge.pro { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

main { max-width: 560px; margin: 0 auto; padding: 16px; outline: none; }
.demo-banner {
  max-width: 560px; margin: 8px auto 0; padding: 8px 16px; font-size: .8rem; text-align: center;
  background: var(--warn-soft); color: var(--warn); border-radius: 12px;
}

/* Cartões */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.big { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.hero-card { background: var(--primary); color: var(--primary-ink); border: 0; }
.hero-card .muted, .hero-card .eyebrow { color: color-mix(in srgb, var(--primary-ink) 78%, transparent); }
.hero-card .btn.ghost { color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary-ink) 40%, transparent); }
.hero-card .btn.light { background: var(--primary-ink); color: var(--primary); }
.hero-card.late { background: var(--accent); }
.hero-card.late .btn.light { color: var(--accent); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack > * + * { margin-top: 10px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.accent { background: var(--accent); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.danger { color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px;
  border-radius: 10px; min-width: 40px; min-height: 40px;
}
.icon-btn:hover { background: var(--surface-2); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* Formulários */
label.field { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea, .input {
  display: block; width: 100%; margin-top: 4px; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font-weight: 500;
}
textarea { resize: vertical; min-height: 70px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); font-size: .9rem; cursor: pointer; user-select: none;
}
.chip input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale .chip span { display: block; text-align: center; padding: 10px 0; border-radius: 12px; }
.scale .chip:nth-child(4) input:checked + span, .scale .chip:nth-child(5) input:checked + span { background: var(--accent); }

/* Progresso / metas */
.goal { padding: 12px 0; border-top: 1px solid var(--line); }
.goal:first-of-type { border-top: 0; padding-top: 0; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .25s; }
.bar.water > i { background: #3a8fd0; }
.bar.done > i { background: var(--ok); }
.habit-list { display: grid; gap: 6px; margin-top: 4px; }
.habit {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer;
}
.habit .box {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; font-size: 14px; color: transparent;
}
.habit.on .box { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.habit.on { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .when { flex: none; width: 52px; text-align: center; background: var(--surface-2); border-radius: 12px; padding: 6px 0; }
.list .when b { display: block; font-size: 1.05rem; }
.list .when small { font-size: .7rem; color: var(--muted); text-transform: uppercase; }
.list .body { flex: 1; min-width: 0; }
.list .body p { margin: 2px 0 0; font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.pill.hot { background: var(--accent-soft); color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; font-size: .92rem; }

.lock-note {
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: .88rem;
}
.notice { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: .85rem; color: var(--muted); }
.notice.alert { background: var(--accent-soft); color: var(--accent); }
.disclaimer { font-size: .78rem; color: var(--muted); text-align: center; margin: 18px 8px 6px; }

/* Mapa de aplicação */
.map-wrap { display: grid; grid-template-columns: minmax(0, 190px) 1fr; gap: 14px; align-items: center; }
.bodymap { width: 100%; height: auto; display: block; }
.bodymap .silhouette > * { fill: var(--body); }
.bodymap .zone { stroke: var(--surface); stroke-width: 2; cursor: pointer; transition: opacity .15s; }
.bodymap .zone:hover { opacity: .8; }
.bodymap .z-never { fill: var(--zone-never); }
.bodymap .z-old { fill: var(--zone-old); }
.bodymap .z-recent { fill: var(--zone-recent); }
.bodymap .z-last { fill: var(--zone-last); }
.bodymap .z-sel { stroke: var(--ink); stroke-width: 3.5; }
.bodymap .navel { fill: var(--muted); }
.bodymap .side { font-size: 11px; font-weight: 700; fill: var(--muted); }
.legend { display: grid; gap: 6px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }

/* Gráficos */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .lbl { font-size: 10px; fill: var(--muted); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.alt { stroke: var(--accent); }
.chart .area { fill: var(--primary); opacity: .1; }
.chart .dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart .barr { fill: var(--primary); }
.chart .barr.hot { fill: var(--accent); }
.chart .val { font-size: 10px; fill: var(--ink); font-weight: 700; }
.chart-empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: .9rem; background: var(--surface-2); border-radius: 14px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 10px; }
.stat b { display: block; font-size: 1.15rem; }
.stat small { color: var(--muted); font-size: .72rem; }

/* Fotos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos figure { margin: 0; }
.photos img, .compare img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: var(--surface-2); display: block; }
.photos figcaption, .compare figcaption { font-size: .75rem; color: var(--muted); text-align: center; margin-top: 4px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare figure { margin: 0; }

/* Segmentado */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Menu "Mais" */
.menu { list-style: none; margin: 0; padding: 0; }
.menu a, .menu button {
  display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 10px;
  padding: 14px 2px; border: 0; border-top: 1px solid var(--line); background: none; text-decoration: none;
  color: var(--ink); font-weight: 600; cursor: pointer; text-align: left;
}
.menu li:first-child a, .menu li:first-child button { border-top: 0; }
.menu small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }

/* Barra de abas */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  font-size: .7rem; font-weight: 600; color: var(--muted); text-decoration: none; border-radius: 12px;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--primary); }
.tabbar a.on svg { stroke-width: 2.3; }

/* Modal e toast */
dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto;
  border: 0; border-radius: 22px; padding: 20px; background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 20, 19, .55); }
.price { font-size: 2rem; font-weight: 800; color: var(--primary); }
.price small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.benefits { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.benefits li { padding-left: 28px; position: relative; font-size: .95rem; }
.benefits li::before {
  content: "✓"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-size: .75rem; font-weight: 800; display: grid; place-items: center;
}
#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Relatório */
.report { background: #fff; color: #1a1a1a; border-radius: var(--radius); padding: 20px; border: 1px solid var(--line); }
.report h1 { font-size: 1.3rem; }
.report h2 { font-size: 1rem; margin-top: 18px; padding-bottom: 4px; border-bottom: 2px solid #0f6e66; color: #0f6e66; }
.report table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.report th, .report td { text-align: left; padding: 5px 6px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.report th { background: #f3f5f4; font-weight: 700; }
.report .meta { font-size: .82rem; color: #555; }
.report .kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.report .kpis div { border: 1px solid #e3e3e3; border-radius: 10px; padding: 8px; }
.report .kpis b { display: block; font-size: 1.05rem; }
.report .kpis small { color: #666; font-size: .72rem; }
.report .warn { font-size: .78rem; color: #555; border: 1px solid #ddd; border-radius: 10px; padding: 8px 10px; margin-top: 10px; }
.report .notes { white-space: pre-wrap; border: 1px solid #ddd; border-radius: 10px; padding: 10px; min-height: 60px; font-size: .9rem; }
.report .chart .grid { stroke: #e5e5e5; }
.report .chart .lbl { fill: #666; }
.report .chart .line { stroke: #0f6e66; }
.report .chart .dot { fill: #fff; stroke: #0f6e66; }
.report .chart .area { fill: #0f6e66; }
.report .chart .barr { fill: #0f6e66; }
.report .chart .val { fill: #1a1a1a; }
.report .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.locked-preview { position: relative; overflow: hidden; border-radius: var(--radius); }
.locked-preview .report { filter: blur(3px); opacity: .6; pointer-events: none; user-select: none; }
.locked-preview .over {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center;
  background: linear-gradient(transparent, color-mix(in srgb, var(--bg) 85%, transparent) 40%);
}

@media (max-width: 380px) {
  main { padding: 12px; }
  .map-wrap { grid-template-columns: 1fr; }
  .bodymap { max-width: 200px; margin: 0 auto; }
  .stat-row, .report .kpis { grid-template-columns: 1fr 1fr; }
  .report .two { grid-template-columns: 1fr; }
  .big { font-size: 1.6rem; }
}

@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; padding: 0; color: #000; }
  .no-print, .topbar, .tabbar, .demo-banner, #toast, dialog { display: none !important; }
  main { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; border-radius: 0; }
  .report h2 { break-after: avoid; }
  .report tr, .report .chart, .report .kpis { break-inside: avoid; }
}

/* Conta e planos */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.plan-mini { background: var(--surface-2); border-radius: 14px; padding: 10px; display: grid; gap: 2px; text-align: center; }
.plan-mini span { font-weight: 800; color: var(--primary); }
.plan-mini small { font-size: .7rem; color: var(--muted); line-height: 1.25; }
.plan-list { display: grid; gap: 12px; }
.plan-opt { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--bg); }
.plan-opt .price { font-size: 1.6rem; margin: 2px 0 4px; }
.pix-qr { display: block; width: 220px; max-width: 100%; margin: 6px auto 12px; border-radius: 12px; background: #fff; padding: 8px; }
@media (max-width: 380px) { .plans { grid-template-columns: 1fr; } }
