* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #f4f4f2;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: #111;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
input::placeholder { color: #b7b7b7; }
input:focus { border-color: #111 !important; }
button { font-family: inherit; }
input[type="date"] { max-width: 100%; }

/* ---- auth ---- */
.auth-screen { max-width: 400px; margin: 0 auto; padding: 72px 28px; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; background: #fff; }
.auth-kicker { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: #a3a3a3; }
.auth-title { font-size: 30px; font-weight: 600; margin: 12px 0 0; letter-spacing: -0.6px; line-height: 1.1; }
.auth-sub { font-size: 13px; color: #8a8a8a; margin: 10px 0 0; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 38px; }
.field-input { width: 100%; box-sizing: border-box; padding: 14px 14px; border: 1px solid #e0e0e0; border-radius: 9px; font-size: 15px; font-family: inherit; color: #111; outline: none; background: #fff; }
.btn-primary { border: none; background: #111; color: #fff; padding: 15px 16px; border-radius: 9px; font-size: 14px; letter-spacing: 0.3px; cursor: pointer; margin-top: 4px; width: 100%; }
.btn-link { border: none; background: none; color: #6b6b6b; font-size: 13px; cursor: pointer; padding: 16px 0 0; text-align: center; width: 100%; display: block; }
.auth-error { font-size: 12.5px; color: #111; background: #f0f0f0; padding: 10px 12px; border-radius: 8px; }
.auth-demo { margin-top: 28px; padding-top: 18px; border-top: 1px solid #f0f0f0; font-size: 12px; color: #a3a3a3; text-align: center; line-height: 1.6; }
.field-errors { font-size: 12px; color: #c0392b; margin-top: -6px; }

/* ---- shell ---- */
.shell { min-height: 100vh; background: #f4f4f2; }
.card { max-width: 480px; margin: 0 auto; min-height: 100vh; background: #fff; padding: 30px 24px 110px; position: relative; }

.app-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; }
.app-kicker { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #a3a3a3; }
.app-title { font-size: 27px; font-weight: 600; margin: 7px 0 0; letter-spacing: -0.6px; }
.app-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #111; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.logout-btn { border: none; background: none; color: #9a9a9a; font-size: 12px; cursor: pointer; padding: 4px; }

/* ---- nav ---- */
.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px; background: #fff; border-top: 1px solid #ededed; display: flex; z-index: 50; }
.nav-item { flex: 1; border: none; background: none; padding: 16px 0 20px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; cursor: pointer; color: #bdbdbd; font-weight: 400; text-align: center; display: block; }
.nav-item.active { color: #111; font-weight: 600; }
.back-nav { justify-content: flex-start; padding: 14px 16px; }
.back-link { font-size: 12.5px; color: #6b6b6b; }

/* ---- score ring ---- */
.score-wrap { display: flex; flex-direction: column; align-items: center; padding: 6px 0 26px; }
.score-ring { position: relative; width: 172px; height: 172px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring-fill { transition: stroke-dashoffset .5s ease; }
.score-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-value { font-size: 46px; font-weight: 600; letter-spacing: -2px; line-height: 1; }
.score-max { font-size: 12px; color: #a3a3a3; letter-spacing: 1px; margin-top: 2px; }
.score-caption { font-size: 12.5px; color: #8a8a8a; margin-top: 14px; letter-spacing: 0.2px; }

/* ---- item list (tareas + hábitos de hoy) ---- */
.item-list { border-top: 1px solid #eee; }
.item-row { display: flex; align-items: center; gap: 14px; padding: 15px 2px; border-bottom: 1px solid #f1f1f1; }
.item-box { width: 24px; height: 24px; flex: none; border-radius: 7px; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; border: 1.6px solid #111; background: #fff; }
.item-box.done { background: #111; }
.item-box[disabled] { cursor: default; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 500; }
.item-title.done { color: #bdbdbd; text-decoration: line-through; }
.item-meta { font-size: 10.5px; color: #b3b3b3; letter-spacing: 1px; text-transform: uppercase; margin-top: 3px; }
.item-points { font-size: 12px; color: #bdbdbd; font-variant-numeric: tabular-nums; }
.item-remove { border: none; background: none; color: #cfcfcf; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.item-chevron { color: #d4d4d4; font-size: 17px; line-height: 1; padding: 0 0 0 2px; }

.empty-state { text-align: center; color: #b3b3b3; font-size: 13px; padding: 36px 0; }

.add-form { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.add-form input[type="text"],
.add-form input[type="date"] {
  min-width: 0;
  border: 1px solid #e0e0e0;
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: #111;
  outline: none;
  background: #fff;
  padding: 13px 14px;
}
.add-form input[type="text"] { flex: 1 1 140px; }
.add-form input[type="date"] { flex: 1 1 130px; width: auto; color: #6b6b6b; font-size: 13px; padding: 13px 10px; }
.btn-add { flex: none; border: none; background: #111; color: #fff; padding: 13px 18px; border-radius: 9px; font-size: 13px; cursor: pointer; }

.section { margin-top: 8px; }
.section + .section { margin-top: 36px; padding-top: 6px; border-top: 1px solid #f1f1f1; }
.section-label { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: #a3a3a3; margin-bottom: 10px; }

.upcoming { margin-top: 28px; }
.upcoming-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px solid #f5f5f5; font-size: 14px; }
.upcoming-date { font-size: 11px; color: #b3b3b3; }

/* ---- detalle de tarea / subtareas ---- */
.task-desc { font-size: 14px; color: #6b6b6b; line-height: 1.6; margin-bottom: 24px; }
.subtask-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid #f1f1f1; }

/* ---- hábitos ---- */
.habit-form { border: 1px solid #e8e8e8; border-radius: 12px; padding: 18px; margin-bottom: 18px; background: #fafafa; }
.field-label { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: #a3a3a3; margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.chip { display: inline-block; border: 1px solid #e0e0e0; background: #fff; color: #6b6b6b; padding: 9px 14px; border-radius: 20px; font-size: 12.5px; cursor: pointer; }
.day-row { display: flex; gap: 6px; margin-bottom: 14px; }
.day-chip { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid #e0e0e0; background: #fff; color: #9a9a9a; border-radius: 50%; font-size: 13px; cursor: pointer; }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; }
.btn-secondary { display: inline-block; border: 1px solid #e0e0e0; background: #fff; color: #6b6b6b; padding: 11px 18px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.btn-dark { border: none; background: #111; color: #fff; padding: 11px 20px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.btn-dashed { display: block; width: 100%; box-sizing: border-box; text-align: center; border: 1px dashed #d0d0d0; background: #fff; color: #111; padding: 14px; border-radius: 10px; font-size: 14px; cursor: pointer; margin-bottom: 20px; }

/* chips / checkboxes / toggle implementados con inputs nativos + CSS :has(), sin JS */
.chip-radio, .day-chip-checkbox, .form-toggle-checkbox {
  position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; pointer-events: none;
}
.chip-radio:focus-visible + .chip, .day-chip-checkbox:focus-visible + .day-chip { outline: 2px solid #111; outline-offset: 1px; }
.chip-radio:checked + .chip { border-color: #111; background: #111; color: #fff; }
.day-chip-checkbox:checked + .day-chip { border-color: #111; background: #111; color: #fff; }

.conditional-day-row { display: none; }
.habit-form:has(#freq-days:checked) .conditional-day-row { display: flex; }

.habit-toggle-wrap .conditional-form { display: none; }
.habit-toggle-wrap:has(.form-toggle-checkbox:checked) .conditional-form { display: block; }
.habit-toggle-wrap:has(.form-toggle-checkbox:checked) .toggle-open-label { display: none; }

.habit-row { display: flex; align-items: center; gap: 14px; padding: 16px 2px; border-bottom: 1px solid #f1f1f1; }
.habit-title { font-size: 15px; font-weight: 500; }
.habit-meta { font-size: 10.5px; color: #b3b3b3; letter-spacing: 1px; text-transform: uppercase; margin-top: 3px; }
.habit-locked { font-size: 11px; color: #c4c4c4; }

/* ---- agua ---- */
.water-wrap { display: flex; flex-direction: column; align-items: center; }
.water-tank { position: relative; width: 138px; height: 240px; border: 2px solid #111; border-radius: 14px; overflow: hidden; background: #fff; margin-top: 6px; flex: none; }
.water-fill { position: absolute; left: 0; right: 0; bottom: 0; background: #1c1c1c; transition: height .45s ease; }
.water-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; mix-blend-mode: difference; color: #fff; }
.water-ml { font-size: 30px; font-weight: 600; letter-spacing: -1px; }
.water-caption { font-size: 12.5px; color: #8a8a8a; margin-top: 16px; }
.water-side { display: flex; flex-direction: column; align-items: center; width: 100%; }
.water-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 24px; }
.water-btn { border: 1px solid #e0e0e0; background: #fff; color: #111; padding: 16px; border-radius: 11px; font-size: 15px; cursor: pointer; font-family: inherit; }
.water-reset { border: none; background: none; color: #a3a3a3; font-size: 12.5px; cursor: pointer; margin-top: 18px; padding: 6px; }

/* ---- dashboard ---- */
.dash-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.stat-card { border: 1px solid #f0f0f0; border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.dash-label { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: #a3a3a3; margin-bottom: 10px; }
.dash-stat { font-size: 32px; font-weight: 600; letter-spacing: -1px; }
.dash-stat-sub { font-size: 12.5px; color: #8a8a8a; margin-top: 4px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.habit-fail-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px solid #f1f1f1; font-size: 13.5px; gap: 10px; }
.habit-fail-name { flex: 1; min-width: 0; }
.fail-bar-track { flex: 1.4; height: 6px; background: #ececec; border-radius: 3px; overflow: hidden; }
.fail-bar-fill { height: 100%; background: #111; }
.habit-fail-pct { font-size: 12px; color: #8a8a8a; font-variant-numeric: tabular-nums; width: 36px; text-align: right; }
.chart-wrap { position: relative; height: 180px; }

/* ---- responsive (desktop) ---- */
@media (min-width: 700px) {
  .card { max-width: 760px; padding: 38px 44px 60px; }

  .bottom-nav { position: static; left: auto; transform: none; bottom: auto; width: auto; max-width: none; margin: 0 0 32px; border-top: none; border-bottom: 1px solid #ededed; }
  .nav-item { padding: 0 0 16px; flex: none; padding-left: 22px; padding-right: 22px; }

  .dash-grid { grid-template-columns: 1.3fr 1fr; align-items: start; }

  .water-wrap { flex-direction: row; align-items: flex-start; gap: 56px; justify-content: center; margin-top: 10px; }
  .water-side { width: 260px; }
  .water-grid { margin-top: 0; }

  .item-row:hover { background: #fafafa; }
  .habit-row:hover { background: #fafafa; }
}

@media (min-width: 1000px) {
  .card { max-width: 920px; }
}
