/* Mi Vivero: estilos mobile-first, sin fuentes externas. */

:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --text: #1c271f;
  --muted: #56645a;
  --border: #dbe2d7;
  --green: #2e6b3f;
  --green-strong: #1f5130;
  --green-soft: #e3efe0;
  --urgent: #b3261e;
  --urgent-soft: #fbe8e6;
  --important: #8a5300;
  --important-soft: #fcefd6;
  --focus-star: #6b4fa8;
  --focus-soft: #eee8f8;
  --ring: #1b66d1;
  --radius: 14px;
  --tabbar-h: 4rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111612;
    --surface: #1a211c;
    --text: #e7ede8;
    --muted: #a5b3a8;
    --border: #2d3830;
    --green: #6fbf84;
    --green-strong: #8fd4a1;
    --green-soft: #213528;
    --urgent: #ff8a80;
    --urgent-soft: #3b1f1d;
    --important: #f2b84b;
    --important-soft: #3a2e15;
    --focus-star: #c3a9f5;
    --focus-soft: #2c2540;
    --ring: #7fb0ff;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 5rem);
}

a {
  color: var(--green-strong);
}

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ico {
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- Estructura ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 1rem 0.5rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--green-strong);
}

.view {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
  outline: none;
}

.view-head {
  margin: 0.25rem 0 1rem;
}

.view-head h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
  outline: none;
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.9rem;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
}

.loading,
.empty,
.empty-day {
  color: var(--muted);
}

.empty-day {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.25rem 0 0.75rem;
}

.count {
  display: inline-block;
  min-width: 1.6rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-strong);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
}

.card-focus {
  border: 2px solid var(--green);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

details.card > summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 2rem;
}

.link-sm {
  font-size: 0.9rem;
}

.group {
  margin: 0 0 1rem;
}

.group-danger > h2 {
  color: var(--urgent);
}

.group-urgent > h2 {
  color: var(--urgent);
}

.banner {
  display: block;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--text);
  text-decoration: none;
}

.banner-warn {
  background: var(--important-soft);
}

/* ---------- Botones ---------- */

button {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.9rem;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .btn {
    color: #0d1a11;
  }
}

.btn:disabled {
  opacity: 0.6;
}

.btn-soft {
  background: var(--green-soft);
  color: var(--green-strong);
}

.btn-danger {
  background: var(--urgent-soft);
  color: var(--urgent);
}

.btn-block {
  display: flex;
  width: 100%;
  margin: 0 0 1rem;
}

.btn.sm {
  min-height: 2.4rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--green-strong);
  text-decoration: underline;
  cursor: pointer;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.9rem;
  height: 2.9rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  flex: none;
}

.icon-btn.sm {
  width: 2.5rem;
  height: 2.5rem;
}

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.quick .btn {
  flex: 1 1 auto;
  font-size: 0.92rem;
}

.stack {
  display: grid;
  gap: 0.5rem;
}

/* ---------- Tareas ---------- */

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.7rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--border);
}

.task-list > .task:first-child {
  border-top: 0;
}

.check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid var(--green);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
}

.check:hover {
  color: var(--green);
}

.prio-urgente .check {
  border-color: var(--urgent);
}

.prio-importante .check {
  border-color: var(--important);
}

.check.is-done {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.check.is-projected {
  border-style: dashed;
  border-color: var(--border);
  color: var(--muted);
  cursor: default;
}

.task-body {
  min-width: 0;
}

.task-title {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0 0.15rem;
  border: 0;
  background: none;
  text-align: left;
  font-weight: 650;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.task-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 500;
}

.task-projected .task-title {
  color: var(--muted);
  font-weight: 500;
}

.task-notes {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.task-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  min-height: 2rem;
}

.task-link .ico {
  width: 1rem;
  height: 1rem;
}

.top3 .task-title {
  font-size: 1.08rem;
}

.compact .task {
  padding: 0.35rem 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-strong);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip-muted {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.chip-danger,
.chip-urgente {
  background: var(--urgent-soft);
  color: var(--urgent);
}

.chip-importante {
  background: var(--important-soft);
  color: var(--important);
}

.chip-focus {
  background: var(--focus-soft);
  color: var(--focus-star);
}

/* ---------- Semana y mes ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.pager-label {
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.day {
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.day.is-today {
  border-top: 3px solid var(--green);
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.day-head h2 {
  margin: 0;
}

.day-date {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.calendar {
  margin: 0 0 1rem;
}

.cal-head,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.cal-head span {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  padding-bottom: 0.25rem;
}

.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.cal-day.is-other {
  opacity: 0.45;
}

.cal-day.is-today {
  border: 2px solid var(--green);
}

.cal-day.is-selected {
  background: var(--green);
  color: #fff;
}

.cal-dot {
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-strong);
}

.cal-day.is-late .cal-dot {
  background: var(--urgent-soft);
  color: var(--urgent);
}

/* ---------- Metas y estadísticas ---------- */

.goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.goal-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.goal-ok {
  color: var(--green-strong);
  font-size: 0.8rem;
  font-weight: 700;
}

progress {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.65rem;
  margin-top: 0.3rem;
  border: 0;
  border-radius: 999px;
  background: var(--green-soft);
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: var(--green-soft);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--green);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--green);
  border-radius: 999px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.stats dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.stats dd {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.stats .neg {
  color: var(--urgent);
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.95rem;
}

.table th,
.table td {
  padding: 0.4rem 0.25rem;
  border-top: 1px solid var(--border);
  text-align: right;
}

.table th:first-child {
  text-align: left;
}

.goal-set {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem 0.25rem;
}

.goal-set legend {
  font-weight: 700;
  padding: 0 0.25rem;
}

/* ---------- Registros ---------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.tabs a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.tabs a[aria-current='page'] {
  background: var(--green);
  color: #fff;
}

.record-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.record {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.75rem;
  margin: 0 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.record-main {
  font-weight: 650;
}

.record-sub,
.record-notes {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.menu {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.menu a {
  display: grid;
  gap: 0.1rem;
  padding: 0.85rem 1rem;
  margin: 0 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}

.menu small {
  color: var(--muted);
  font-weight: 400;
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
}

.steps li {
  margin: 0 0 0.4rem;
}

.reviews {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.reviews li {
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.reviews p {
  margin: 0.25rem 0 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.search-row input {
  flex: 1;
}

/* ---------- Formularios ---------- */

label {
  display: block;
  margin: 0 0 0.85rem;
  font-weight: 600;
  font-size: 0.92rem;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 2.9rem;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* evita zoom automático en iPhone */
  font-weight: 400;
}

textarea {
  resize: vertical;
}

input[type='checkbox'],
input[type='radio'] {
  width: 1.3rem;
  height: 1.3rem;
  min-height: 0;
  margin: 0;
  accent-color: var(--green);
}

.row2,
.row3 {
  display: grid;
  gap: 0 0.6rem;
}

.row2 {
  grid-template-columns: 1fr 1fr;
}

.row3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
}

fieldset {
  border: 0;
  margin: 0 0 0.85rem;
  padding: 0;
  min-width: 0;
}

legend {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
  padding: 0;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.segmented legend {
  width: 100%;
}

.seg {
  position: relative;
  flex: 1 1 auto;
  margin: 0;
}

.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  text-align: center;
}

.seg input:checked + span {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.seg-urgente input:checked + span {
  background: var(--urgent);
  border-color: var(--urgent);
}

.seg-importante input:checked + span {
  background: var(--important);
  border-color: var(--important);
}

.seg input:focus-visible + span {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.pick-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.6rem 0;
  margin: 0;
  border-top: 1px solid var(--border);
  font-weight: 400;
}

.pick-item input {
  margin-top: 0.15rem;
}

.pick-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.form-error {
  margin: 0 0 0.85rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: var(--urgent-soft);
  color: var(--urgent);
  font-weight: 600;
}

.file-btn {
  cursor: pointer;
}

/* ---------- Hoja inferior (dialog) ---------- */

.sheet {
  width: 100%;
  max-width: 40rem;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--text);
  overflow: auto;
  overscroll-behavior: contain;
}

.sheet::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.sheet-body {
  padding: 0.75rem 1rem calc(1rem + var(--safe-b));
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.2rem;
  outline: none;
}

.sheet-sub {
  margin: -0.25rem 0 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.sheet-actions {
  display: flex;
  gap: 0.5rem;
}

.sheet-actions .btn {
  flex: 1;
}

.quick-menu .btn-block {
  margin-bottom: 0.6rem;
}

.quick-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.quick-dates .btn {
  flex-direction: column;
  gap: 0;
  border-radius: 12px;
  line-height: 1.2;
}

.quick-dates small {
  font-weight: 400;
  font-size: 0.75rem;
}

/* ---------- Barra inferior, botón flotante, avisos ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
}

.tabbar a[aria-current='page'] {
  color: var(--green-strong);
}

.tabbar a[aria-current='page'] .ico {
  stroke-width: 2.6;
}

.fab {
  position: fixed;
  right: max(1rem, calc((100vw - 40rem) / 2 + 1rem));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 1rem);
  z-index: 11;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.6rem;
  height: 3.6rem;
  border: 0;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.25);
  cursor: pointer;
}

.fab .ico {
  width: 1.8rem;
  height: 1.8rem;
  stroke-width: 2.6;
}

.update {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 40rem;
  margin: 0.75rem auto 0;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  border-radius: var(--radius);
  background: var(--focus-soft);
}

.toast {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 5.5rem);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 38rem;
  margin: 0 auto;
  padding: 0.6rem 0.6rem 0.6rem 1rem;
  border-radius: 12px;
  background: #1f2a22;
  color: #fff;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.toast-error {
  background: #8c1d18;
}

.toast p {
  flex: 1;
  margin: 0;
  overflow-wrap: anywhere;
}

.toast button {
  min-height: 2.6rem;
  padding: 0 0.8rem;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.15);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
