:root {
  --bg: #F6F7F4;
  --card: #FFFFFF;
  --ink: #1B2A2F;
  --muted: #4A5A5F;
  --soft: #EEF0EC;
  --line: #D5DBD7;
  --brand: #0F766E;
  --brand-dark: #0F5F58;
  --brand-soft: #E3F2EF;
  --warn: #9A3409;
  --warn-strong: #C2410C;
  --warn-soft: #FFF4EC;
  --warn-line: #F6C9A8;
  --danger: #B42318;
  --shadow: 0 1px 2px rgba(27, 42, 47, 0.06);
  --radius: 18px;
  --nav-h: 72px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; padding: 24px 20px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.screen.no-nav { padding-bottom: 40px; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.head h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.sub { color: var(--muted); font-size: 15px; margin: -8px 0 0; }
.backbar { display: flex; align-items: center; gap: 4px; margin: -8px 0 0 -12px; }
.backbar h1 { font-size: 22px; margin: 0; font-weight: 800; }
h2.section { margin: 4px 0 -4px; font-size: 14px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card.flush { padding: 0; gap: 0; }
.card.link { text-decoration: none; color: inherit; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--soft); text-decoration: none; color: inherit; }
.list-item:last-child { border-bottom: none; }
.title { font-size: 16px; font-weight: 800; }
.meta { font-size: 14px; color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 800; }
.empty { color: var(--muted); font-size: 15px; padding: 8px 2px; }

.btn { min-height: 48px; border-radius: 14px; border: none; padding: 0 18px; font-weight: 800; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.secondary { background: var(--card); color: var(--brand); border: 1.5px solid var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid #E7B4AE; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; border-radius: 16px; font-size: 17px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.icon-btn.fill { background: var(--brand); color: #fff; }

.pill { min-height: 44px; min-width: 92px; border-radius: 22px; border: none; font-weight: 800; font-size: 15px; cursor: pointer; padding: 0 14px; }
.pill.todo { background: var(--brand); color: #fff; }
.pill.done { background: var(--brand-soft); color: var(--brand-dark); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--card); color: #34444A; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .dot { width: 10px; height: 10px; border-radius: 5px; }

.tag { display: inline-flex; padding: 4px 9px; border-radius: 9px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.tag.ok { background: var(--brand-soft); color: var(--brand-dark); }
.tag.neutral { background: var(--soft); color: #34444A; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.dark { background: var(--ink); color: #fff; }

.alert { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 16px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; color: #6B3A1F; text-decoration: none; }
.alert .title { color: #8A3208; font-size: 15px; }
.info { background: var(--brand-soft); border-radius: 16px; padding: 12px 14px; font-size: 14px; color: #1F4F4A; }

.avatar { width: 46px; height: 46px; border-radius: 23px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.datebox { width: 52px; height: 56px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.datebox b { font-size: 20px; line-height: 1; }
.datebox span { font-size: 12px; font-weight: 800; text-transform: uppercase; }
.colorbar { width: 5px; align-self: stretch; border-radius: 3px; flex-shrink: 0; }

.bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.bar > div { height: 8px; border-radius: 4px; background: var(--brand); }
.bar.low > div { background: var(--warn-strong); }

/* Formulários */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: 14px; font-weight: 800; }
.field .hint { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card);
  padding: 10px 14px; font-size: 16px; width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: 15px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); flex-shrink: 0; }
.check .meta { font-weight: 500; }
.checks { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 4px 14px; }
.checks .check + .check { border-top: 1px solid var(--soft); }
.palette { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 40px; height: 40px; border-radius: 20px; border: 3px solid transparent; cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 3px #fff; }
.times { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.times input { width: 120px; min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line); padding: 0 10px; font-size: 16px; background: var(--card); }
.time-chip { display: inline-flex; align-items: center; gap: 2px; }

.seg { display: inline-flex; background: #E9ECE7; border-radius: 12px; padding: 3px; }
.seg button { min-height: 38px; padding: 0 14px; border: none; border-radius: 10px; background: transparent; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 800; }

/* Calendário */
.cal { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 8px 8px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px; }
.cal-head b { font-size: 17px; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.cal-wd { font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day { height: 48px; border: none; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
.cal-day .n { width: 34px; height: 34px; border-radius: 17px; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; border: 1.5px solid transparent; }
.cal-day.today .n { border-color: var(--brand); color: var(--brand-dark); font-weight: 800; }
.cal-day.sel .n { background: var(--brand); color: #fff; font-weight: 800; }
.cal-day .dots { display: flex; gap: 3px; height: 6px; }
.cal-day .dots i { width: 6px; height: 6px; border-radius: 3px; }

/* Navegação inferior */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid #E4E7E1; padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); z-index: 10; }
.nav-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; text-decoration: none; color: #5B6B70; font-size: 12px; font-weight: 600; }
.nav a[aria-current="page"] { color: var(--brand); font-weight: 800; }

/* Login */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 24px; padding: 32px 24px; max-width: 440px; margin: 0 auto; }
.login img { width: 88px; height: 88px; border-radius: 22px; }
.login h1 { font-size: 32px; margin: 0; font-weight: 800; letter-spacing: -0.6px; }
.login p { margin: 0; color: var(--muted); font-size: 17px; }
.gbtn { background: #fff; color: #1F1F1F; border: 1.5px solid #747775; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 600; z-index: 20; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,0.18); }
.toast.error { background: var(--danger); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--soft); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 600px) {
  .screen { padding-top: 36px; }
}
