:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --text: #1c1b19;
  --muted: #7a776f;
  --line: #e4e2db;
  --accent: #1c1b19;
  --accent-text: #ffffff;
  --danger: #d4452f;
  --danger-bg: #fdecea;
  --ok: #2f9e6e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --nav-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --surface: #1e1e1d;
    --surface-2: #2a2a28;
    --text: #f1efe9;
    --muted: #9b978d;
    --line: #2f2f2c;
    --accent: #f1efe9;
    --accent-text: #141414;
    --danger: #ff6b55;
    --danger-bg: #3a1f1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 8px 0 0; font-size: 28px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 8px; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.logo.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 15px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px;
  font-size: 16px; outline: none; width: 100%; color: var(--text);
}
input:focus, textarea:focus { border-color: var(--muted); }
textarea { resize: vertical; }
.error { color: var(--danger); font-size: 14px; margin: 0; }

/* ---------- Botões ---------- */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; font-size: 15px; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); width: 36px; height: 36px; border-radius: 10px; font-size: 20px; line-height: 1; }

/* ---------- Layout ---------- */
.app { min-height: 100dvh; }
.main { max-width: 760px; margin: 0 auto; padding: 24px 18px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav-item { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted); }
.nav-item .ico { font-size: 18px; font-weight: 700; height: 22px; }
.nav-item.active { color: var(--text); }
.nav-item.active .ico { transform: scale(1.08); }

@media (min-width: 900px) {
  .nav { top: 0; right: auto; width: 220px; height: 100dvh; flex-direction: column; border-top: 0; border-right: 1px solid var(--line);
    padding: 24px 14px; gap: 4px; background: var(--surface); }
  .nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 0 10px 22px; }
  .nav-item { flex: 0; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; border-radius: 10px; font-size: 15px; }
  .nav-item .ico { width: 22px; text-align: center; font-size: 15px; height: auto; }
  .nav-item.active { background: var(--surface-2); }
  .nav-settings { margin-top: auto; }
  .main { margin-left: 220px; margin-right: auto; padding: 40px 48px 120px; max-width: 980px; }
  .fab { right: 40px !important; bottom: 40px !important; }
}

/* ---------- Cabeçalho ---------- */
.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 0 0 12px; font-size: 30px; letter-spacing: -.025em; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 96px; }
.stat b { display: block; font-size: 20px; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.alert b { color: var(--danger); }

/* ---------- Seções e itens ---------- */
.section { margin-top: 22px; }
.section-title { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px 4px; }
.section-title.alert { color: var(--danger); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--line); position: relative; }
.item:first-child { border-top: 0; }
.item .bar { position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: none; display: grid; place-items: center;
  font-size: 13px; color: transparent; transition: .15s; }
.check:hover { border-color: var(--muted); }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.item.bill .check { border-radius: 7px; }
.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-title { font-size: 15.5px; line-height: 1.3; word-wrap: break-word; }
.item.done .item-title { text-decoration: line-through; color: var(--muted); }
.item-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.item-meta .late { color: var(--danger); font-weight: 600; }
.area-tag { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.empty-big { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty-big b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.day-head { padding: 9px 14px 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 4px; text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.month-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.month-nav span { font-weight: 600; min-width: 140px; text-align: center; }

/* ---------- FAB ---------- */
.fab { position: fixed; z-index: 25; right: 20px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-text);
  font-size: 30px; font-weight: 300; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.fab:active { transform: scale(.95); }

/* ---------- Folha ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.sheet { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto;
  animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 12vh; width: 520px; transform: translateX(-50%); border-radius: 22px; padding: 20px 22px; animation: none; }
  .sheet-handle { display: none; }
}
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#item-form { display: flex; flex-direction: column; gap: 12px; }
#f-title { font-size: 18px; padding: 14px; }
.row { display: flex; gap: 10px; }
.quick-dates { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-dates button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

/* ---------- Toast ---------- */
.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--accent-text); padding: 11px 16px; border-radius: 12px; font-size: 14px; display: flex; gap: 14px; align-items: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }
@media (min-width: 900px) { .toast { bottom: 40px; } }

#f-areas { flex-wrap: wrap; overflow: visible; }

/* ---------- Fase 2 ---------- */
select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px;
  font-size: 16px; width: 100%; color: var(--text); appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.card p { margin: 0; }
.card .row-between { display: flex; align-items: center; gap: 12px; width: 100%; }

.star { flex: none; background: none; border: 0; font-size: 18px; color: var(--line); padding: 4px; line-height: 1; }
.star:hover { color: var(--muted); }
.star.on { color: #e5a50a; }
.item.done .star { display: none; }

.item.event .ev-time { flex: none; width: 52px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; }
.item.event .ev-time small { display: block; font-weight: 400; color: var(--muted); }
.item.event .ev-link { flex: none; color: var(--muted); text-decoration: none; font-size: 15px; padding: 4px; }
.item.event.past { opacity: .5; }
.item.projected { opacity: .55; }
.item.projected .check { border-style: dashed; }
.tag-proj { font-size: 11px; border: 1px dashed var(--muted); border-radius: 6px; padding: 0 5px; }

.section-title.focus { color: #b7860b; }
.hint { padding: 14px 16px; font-size: 14px; color: var(--muted); }
.banner { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-size: 14px; color: var(--muted); margin-top: 18px; }
.banner button { margin-left: auto; flex: none; }
.btn.sm { padding: 8px 12px; font-size: 13.5px; }
@media (max-width: 520px) {
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { min-width: 0; padding: 9px 12px; }
  .stat b { font-size: 18px; }
}

/* ---------- Fase 3 ---------- */
.desktop-only { display: none !important; }
@media (min-width: 900px) {
  .desktop-only { display: flex !important; }
  .mobile-only { display: none !important; }
}
.nav-item span:last-child { white-space: nowrap; }
.sub { margin: -6px 0 0; font-size: 14px; }
.row-between { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.seg-inline { max-width: 320px; margin-bottom: 12px; }
input[type="search"] { margin-top: 12px; }
.sheet-title { margin: 4px 0 14px; font-size: 18px; }
#s2-form { display: flex; flex-direction: column; gap: 12px; }
.check-row { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; color: var(--text); }
.check-row input { width: 20px; height: 20px; }
.weekdays { display: flex; gap: 6px; }
.weekdays button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 0; font-size: 13px; }
.weekdays button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Menu "Mais" */
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; border-top: 1px solid var(--line); background: none; padding: 16px; font-size: 16px; text-align: left; }
.menu-item:first-child { border-top: 0; }
.menu-item .ico { width: 22px; text-align: center; color: var(--muted); }
.menu-item .chev { margin-left: auto; color: var(--muted); font-size: 20px; }

/* Notas */
.quick-note { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.quick-note textarea { border: 0; padding: 4px; resize: none; background: transparent; }
.quick-note .chips { flex: 1; }
.notes-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 18px; }
@media (min-width: 640px) { .notes-grid { grid-template-columns: 1fr 1fr; } }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; position: relative; box-shadow: var(--shadow); }
.note-body { white-space: pre-wrap; word-wrap: break-word; font-size: 15px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.note .item-meta { margin-top: 10px; }
.note .pin { position: absolute; top: 10px; right: 12px; font-size: 13px; }

/* Hábitos */
.habit-strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px; scrollbar-width: none; }
.habit-strip::-webkit-scrollbar { display: none; }
.habit-chip { flex: none; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 14px; font-size: 14px; }
.habit-chip.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.habit-chip small { opacity: .8; font-size: 12px; }
.habit-row { padding: 14px; border-top: 1px solid var(--line); }
.habit-row:first-child { border-top: 0; }
.habit-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.habit-name { font-size: 15.5px; flex: 1; }
.streak { font-size: 13px; color: var(--muted); white-space: nowrap; }
.streak.hot { color: #d9730d; font-weight: 600; }
.habit-days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; margin-top: 10px; }
.hday { aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); padding: 0; font-size: 9px; color: var(--muted); display: grid; place-items: center; }
.hday.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.hday.off { opacity: .3; }
.hday.today { outline: 2px solid var(--text); outline-offset: 1px; }

/* Metas */
.goal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 12px; cursor: pointer; box-shadow: var(--shadow); }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.goal-title { font-weight: 600; }
.goal-pct { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.goal-nums { font-size: 14px; color: var(--muted); margin-top: 4px; }
.progress { height: 10px; background: var(--surface-2); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 99px; background: var(--ok); transition: width .3s; }
.goal-hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* Datas */
.date-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-size: 17px; }
.date-when { flex: none; text-align: right; font-size: 13px; color: var(--muted); }
.date-when b { display: block; color: var(--text); font-size: 14px; }
.item.today-date .date-when b { color: var(--ok); }

/* Revisão */
.rev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .rev-grid { grid-template-columns: repeat(4, 1fr); } }
.rev-grid .stat { min-width: 0; }
.rev-areas { padding: 6px 0; }
.rev-area { display: flex; align-items: center; gap: 10px; padding: 8px 14px; font-size: 14px; }
.rev-area .bar-bg { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.rev-area .bar-bg i { display: block; height: 100%; }
.rev-form { display: flex; flex-direction: column; gap: 12px; }
.focus-banner { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #e5a50a; border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 4px; }
.focus-banner b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 3px; }
.today-dates { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.today-date { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14.5px; }
.note.pinned .note-body { padding-right: 22px; }
.logo-img { width: 52px; height: 52px; display: block; }
.logo-img.sm { width: 30px; height: 30px; }
