:root {
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #1c2b23;
  --muted: #6b7a71;
  --accent: #1e7d4f;
  --accent-soft: #e2f2e9;
  --border: #e2e8e3;
  --red: #d64545;
  --yellow: #e0a90f;
  --green: #2f9e63;
  --future: #cfd6d0;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101813;
    --card: #1a241d;
    --text: #e8efe9;
    --muted: #93a398;
    --accent: #4cc98a;
    --accent-soft: #1f3a2c;
    --border: #27332a;
    --future: #3a463d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
main { max-width: 560px; margin: 0 auto; padding: 12px 14px 24px; }
.hidden { display: none !important; }
h1 { font-size: 1.25rem; margin: 0; }

/* ---- header do dia ---- */
.day-header { padding: 8px 0 4px; }
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-title { text-align: center; flex: 1; }
.nav-arrow {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 1.5rem; line-height: 1;
}
.nav-arrow:disabled { opacity: .3; }
.date-label { position: relative; color: var(--muted); font-size: .9rem; display: inline-block; }
.date-label input[type=date] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%;
}
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.progress-bar {
  flex: 1; height: 10px; border-radius: 5px; background: var(--border); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 5px; background: var(--accent);
  transition: width .3s ease;
}
.progress-text { font-size: .85rem; color: var(--muted); min-width: 3.5em; text-align: right; }
.warn {
  margin: 10px 0 0; font-size: .82rem; color: #9a6b00;
  background: rgba(224, 169, 15, .12); border: 1px solid rgba(224, 169, 15, .35);
  padding: 6px 10px; border-radius: 8px;
}

/* ---- seções e itens ---- */
.section-title {
  margin: 20px 0 8px; font-size: .8rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.item {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  padding: 14px; border: 0; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); text-align: left;
  font-size: .95rem; line-height: 1.35; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.item:last-child { border-bottom: 0; }
.item .box {
  flex: 0 0 24px; height: 24px; margin-top: 1px; border-radius: 7px;
  border: 2px solid var(--muted); display: flex; align-items: center;
  justify-content: center; font-size: .85rem; color: transparent;
  transition: all .15s ease;
}
.item.checked .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.item.checked .label { color: var(--muted); text-decoration: line-through; }
.item.saving { opacity: .55; }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; background: var(--accent-soft); color: var(--accent);
}

/* ---- card de tinturas ---- */
.tincture-card {
  margin: 6px 0 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px dashed var(--accent);
}
.tincture-card.pause { background: rgba(224,169,15,.1); border-color: var(--yellow); }
.tincture-title { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.tincture-card.pause .tincture-title { color: #9a6b00; }
.doses { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.dose {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 10px; font-size: .85rem;
}
.dose b { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
.dose.off { opacity: .6; }
.tincture-note { margin: 10px 0 0; font-size: .78rem; color: var(--muted); font-style: italic; }
.pause-msg { margin: 0; font-size: .95rem; font-weight: 600; }

/* ---- visão geral ---- */
.page-header { padding: 8px 0 12px; }
.streak-banner {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; font-size: 1rem; margin-bottom: 14px;
}
.grid30 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.gcell {
  aspect-ratio: 1; border-radius: 10px; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .95rem; font-weight: 700; color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.gcell small { font-size: .62rem; font-weight: 500; opacity: .9; }
.gcell.green { background: var(--green); }
.gcell.yellow { background: var(--yellow); }
.gcell.red { background: var(--red); }
.gcell.future { background: var(--future); color: var(--muted); cursor: default; }
.gcell.is-today { outline: 3px solid var(--accent); outline-offset: 2px; }
.gcell.extra { opacity: .75; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: .8rem; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); } .dot.future { background: var(--future); }
.grid-sep { grid-column: 1 / -1; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 12px; }

/* ---- peso ---- */
.weight-form { display: flex; gap: 8px; margin-bottom: 16px; }
.weight-form input {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px; font-size: .95rem; min-width: 0;
}
.weight-form input[type=date] { flex: 1.4; }
.weight-form input[type=number] { flex: 1; }
.weight-form button {
  border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-weight: 700; padding: 10px 16px; font-size: .95rem;
}
.weight-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.weight-table th, .weight-table td { padding: 10px 12px; text-align: left; font-size: .9rem; border-bottom: 1px solid var(--border); }
.weight-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.weight-table tr:last-child td { border-bottom: 0; }
.delta-down { color: var(--green); font-weight: 600; }
.delta-up { color: var(--red); font-weight: 600; }
.del-btn { border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 2px 6px; }

/* ---- macros ---- */
.paste-box {
  background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px; font-size: .9rem;
}
.paste-box summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.paste-box textarea {
  width: 100%; margin-top: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); padding: 10px; font-size: .85rem;
  font-family: inherit; resize: vertical;
}
.paste-box button {
  margin-top: 8px; border: 0; border-radius: 10px; background: var(--accent-soft);
  color: var(--accent); font-weight: 700; padding: 8px 14px; font-size: .88rem; cursor: pointer;
}
.macro-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.macro-form input[type=date] {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px; font-size: .95rem; align-self: flex-start;
}
.macro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.macro-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.macro-grid input {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px; font-size: 1rem; width: 100%;
}
.macro-form button[type=submit] {
  border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-weight: 700; padding: 12px; font-size: .95rem; cursor: pointer;
}
.table-scroll { overflow-x: auto; }
.macro-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.macro-table th, .macro-table td { padding: 8px 8px; text-align: right; font-size: .85rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.macro-table th:first-child, .macro-table td:first-child { text-align: left; }
.macro-table th { font-size: .78rem; color: var(--muted); }
.macro-table tr:last-child td { border-bottom: 0; }

/* ---- navegação inferior ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: 0; background: none; color: var(--muted);
  font-size: .72rem; padding: 8px 0 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab .tab-icon { font-size: 1.25rem; }
.tab.active { color: var(--accent); font-weight: 700; }

/* ---- login ---- */
.login-wrap {
  min-height: 100svh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px 24px; width: 100%; max-width: 360px; text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-sub { color: var(--muted); font-size: .9rem; margin: 6px 0 20px; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 1rem; text-align: center;
}
.login-form button {
  border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-weight: 700; padding: 12px; font-size: 1rem; cursor: pointer;
}
.login-error { color: var(--red); font-size: .88rem; margin: 14px 0 0; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: calc(76px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); background: #b3261e; color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: .88rem; z-index: 10;
  max-width: 90vw; text-align: center;
}
