:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef1e8;
  --text: #1f2a1c;
  --muted: #687263;
  --border: #dde2d5;
  --accent: #3d7a3a;
  --accent-strong: #2c5e2a;
  --accent-soft: #e2efdc;
  --on-accent: #ffffff;
  --danger: #b3412f;
  --danger-soft: #f8e3df;
  --warn-soft: #fbf0d4;
  --warn: #8a6510;
  --info-soft: #e1ecf7;
  --info: #2f5e8c;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141912;
    --surface: #1c2219;
    --surface-2: #242c20;
    --text: #e4eadf;
    --muted: #97a291;
    --border: #333d2e;
    --accent: #7bbf6f;
    --accent-strong: #9bd68f;
    --accent-soft: #263a22;
    --on-accent: #10200d;
    --danger: #e98a78;
    --danger-soft: #3d2420;
    --warn-soft: #3a3118;
    --warn: #e2c06a;
    --info-soft: #1d2c3b;
    --info: #8fb9e2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Lo que se oculta con el atributo hidden (filtros en vivo) tiene que quedar oculto aunque otra regla le dé
   display, como las tablas que en el celular se muestran como tarjetas. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

.muted { color: var(--muted); }
small { font-size: .85em; }

/* Layout */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .75rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand small { font-weight: 400; color: var(--muted); margin-left: .25rem; }
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.topbar nav a, .topbar nav .link-button {
  padding: .3rem .65rem; border-radius: 6px; color: var(--muted);
}
.topbar nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.topbar nav form { display: inline; }

.container { max-width: 1600px; margin: 0 auto; padding: 1.25rem clamp(16px, 3vw, 40px) 4rem; }

.page-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: 1rem;
}
.page-header .subtitle { color: var(--muted); font-style: italic; margin-top: .15rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { display: inline; }

/* Buttons */
.button, button, input[type=submit] {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; text-decoration: none;
}
.button:hover, button:hover { text-decoration: none; border-color: var(--accent); }
.button-primary, input[type=submit] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.button-primary:hover, input[type=submit]:hover { background: var(--accent-strong); }
.button-danger, input[type=submit].button-danger { background: var(--surface); border-color: var(--border); color: var(--danger); font-weight: 400; }
input[type=submit].button-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.button-danger:hover { border-color: var(--danger); }
.button-small { padding: .2rem .55rem; font-size: .85rem; }
.link-button { background: none; border: none; padding: 0; color: var(--accent-strong); cursor: pointer; font: inherit; }

/* Flash & errors */
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash-notice { background: var(--accent-soft); color: var(--accent-strong); }
.flash-alert { background: var(--danger-soft); color: var(--danger); }
.errors { background: var(--danger-soft); color: var(--danger); padding: .5rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.errors ul { margin: 0; padding-left: 1.1rem; }

/* Cards & tables */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.card + .card { margin-top: 1rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
th.sortable { padding: 0; }
.sort-button {
  display: flex; align-items: center; gap: .3rem; width: 100%; padding: .5rem .75rem;
  border: none; border-radius: 0; background: none; color: inherit;
  font: inherit; text-transform: inherit; letter-spacing: inherit; text-align: left; cursor: pointer;
}
.sort-button:hover { color: var(--text); border-color: transparent; }
.sort-button::after { content: "↕"; opacity: .35; font-size: .9em; }
th[aria-sort="ascending"] .sort-button::after { content: "▲"; opacity: 1; color: var(--accent-strong); }
th[aria-sort="descending"] .sort-button::after { content: "▼"; opacity: 1; color: var(--accent-strong); }
th[aria-sort] .sort-button { color: var(--accent-strong); }
td.num { white-space: nowrap; }
td .sci { display: block; color: var(--muted); font-style: italic; font-size: .85rem; }

.group-heading { font-size: 1.35rem; margin: 2rem 0 .25rem; padding-bottom: .35rem; border-bottom: 2px solid var(--accent); }
.tabs-purpose a { font-weight: 600; }
.category-heading { display: flex; align-items: baseline; gap: .5rem; }
.category-heading .count { color: var(--muted); font-weight: 400; font-size: .9rem; }

/* Badges & tabs */
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-active { background: var(--accent-soft); color: var(--accent-strong); }
.badge-wished { background: var(--info-soft); color: var(--info); }
.badge-unwanted { background: var(--warn-soft); color: var(--warn); }
.badge-dead { background: var(--surface-2); color: var(--muted); }
.kind-fertilizer { background: var(--accent-soft); color: var(--accent-strong); }
.kind-fungicide { background: var(--info-soft); color: var(--info); }
.kind-insecticide { background: var(--warn-soft); color: var(--warn); }
.kind-other { background: var(--surface-2); color: var(--muted); }

/* Problemas de las plantas */
.issue-pest { background: var(--warn-soft); color: var(--warn); }
.issue-fungus { background: var(--info-soft); color: var(--info); }
.issue-disease { background: var(--danger-soft); color: var(--danger); }
.issue-deficiency { background: var(--accent-soft); color: var(--accent-strong); }
.issue-damage, .issue-other { background: var(--surface-2); color: var(--muted); }
.severity-mild { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.severity-moderate { background: var(--warn-soft); color: var(--warn); }
.severity-severe { background: var(--danger-soft); color: var(--danger); }
h1 .badge { vertical-align: middle; }
.text-danger { color: var(--danger); }
.issue-list { padding-top: .25rem; padding-bottom: .25rem; }
.issue { padding: .75rem 0; }
.issue + .issue { border-top: 1px solid var(--border); }
.issue > header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: start; }
.issue-plant { font-weight: 600; margin-right: .35rem; }
.issue-plant::after { content: " ·"; color: var(--muted); }
.issue-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.issue-actions form { display: inline; }
.issue .notes { margin: .4rem 0 0; }
.issue-treatments { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .92rem; }
.issue-treatments li + li { margin-top: .15rem; }
.issue-untreated { margin: .4rem 0 0; font-size: .9rem; }
.issue-resolved > header strong { color: var(--muted); }
.issue-new { margin-bottom: 1rem; }
.issue-new summary { cursor: pointer; font-weight: 600; }
.issue-new[open] summary { margin-bottom: .75rem; }
.issue-alert { border-left: 4px solid var(--warn); margin-bottom: 1rem; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .75rem; }
.tabs a { padding: .35rem .8rem; border-radius: 999px; color: var(--muted); border: 1px solid var(--border); background: var(--surface); }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tabs a:hover { text-decoration: none; }

/* Forms */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters input, .filters select { min-width: 0; }

form .field { margin-bottom: .9rem; }
form label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
form .hint { color: var(--muted); font-size: .85rem; font-weight: 400; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .45rem .6rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
.filters input, .filters select { width: auto; }
textarea { min-height: 5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.checkbox-inline { display: flex; align-items: center; gap: .4rem; font-weight: 400; }
.checkbox-inline input { width: auto; margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.form-narrow { max-width: 640px; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.inline-form .field { margin: 0; flex: 1 1 140px; }

/* Plant picker for bulk applications */
.plant-picker fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 .75rem; padding: .5rem .75rem .75rem; background: var(--surface); }
.plant-picker legend { font-weight: 700; padding: 0 .35rem; }
.plant-picker .options { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .15rem 1rem; }
.plant-picker label { font-weight: 400; display: flex; gap: .4rem; align-items: baseline; margin: 0; }
.plant-picker label input { width: auto; }

/* Definition list for plant details */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem 1.25rem; margin: 0; }
.details dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.details dd { margin: .1rem 0 0; }
.notes { white-space: pre-line; }

.species-layout { display: grid; grid-template-columns: minmax(0, 280px) 1fr; gap: 1rem; align-items: start; }
.species-figure { margin: 0; }
.references { margin: 0; padding-left: 1.1rem; font-size: .85rem; overflow-wrap: anywhere; }
.species-figure figcaption { margin-top: .25rem; }
.species-photo { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
@media (max-width: 640px) { .species-layout { grid-template-columns: 1fr; } }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 4px; }

/* Photos */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.photo-upload { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.photo-upload label.button { margin: 0; font-size: 1rem; }
.photo-upload .caption { flex: 1 1 220px; width: auto; }
.photo-upload.uploading label.button { opacity: .5; pointer-events: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.photo-grid figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.photo-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.photo-grid figcaption { display: flex; justify-content: space-between; gap: .5rem; padding: .35rem .5rem; font-size: .8rem; color: var(--muted); }
.photo-grid figcaption form { display: inline; }
.photo-edit { padding: 0 .5rem .35rem; font-size: .8rem; }
.photo-edit summary { cursor: pointer; color: var(--muted); }
.photo-edit form { display: grid; gap: .3rem; margin-top: .35rem; }
.photo-edit input { width: 100%; box-sizing: border-box; font-size: .85rem; }
.plant-cell { display: flex; gap: .6rem; align-items: flex-start; }
.plant-cell .thumb { flex: none; }
.plant-cell .thumb img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }

/* Calidad de fruta */
.fruit-score { display: flex; gap: .9rem; align-items: flex-start; margin: 1rem 0 .5rem; padding: .75rem; border-radius: var(--radius); background: var(--surface-2); }
.fruit-score-total { font-size: 1.8rem; font-weight: 700; line-height: 1; min-width: 3.2rem; text-align: center; padding: .4rem .3rem; border-radius: 8px; }
.fruit-score-total small { font-size: .8rem; font-weight: 400; }
.score-high { background: var(--accent-soft); color: var(--accent-strong); }
.score-mid { background: var(--warn-soft); color: var(--warn); }
.score-low { background: var(--danger-soft); color: var(--danger); }
.score-pill { display: inline-block; min-width: 1.8rem; text-align: center; padding: .05rem .4rem; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.need-bar { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.need-track { display: inline-block; width: 3rem; height: .4rem; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.need-fill { display: block; height: 100%; border-radius: 999px; }
.need-bar small { min-width: 2.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.need-low .need-fill { background: var(--accent); }
.need-mid .need-fill { background: var(--warn); }
.need-high .need-fill { background: var(--danger); }

.merge-box summary { cursor: pointer; font-weight: 600; }

/* Colores de categoría */
.dot-swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); vertical-align: middle; }
.category-heading .dot-swatch { margin-right: .1rem; }
.color-field { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.color-field input[type=color] { width: 3rem; height: 2.2rem; padding: .1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.color-presets { display: flex; flex-wrap: wrap; gap: .3rem; }
.swatch { width: 1.6rem; height: 1.6rem; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); cursor: pointer; }

.container-note { margin: .75rem 0 0; padding: .6rem .75rem; border-radius: 8px; background: var(--surface-2); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent-strong); font-weight: 600; }

/* Visor de fotos (galería) */
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: none; background: rgba(0,0,0,.92); color: #fff; }
.lightbox::backdrop { background: rgba(0,0,0,.92); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox figure { margin: 0; flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem .5rem 1rem; }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 7rem); object-fit: contain; border-radius: 4px; }
.lightbox figcaption { margin-top: .6rem; font-size: .9rem; color: #ddd; text-align: center; }
.lightbox-counter { position: absolute; top: .9rem; left: 1rem; font-size: .9rem; color: #ccc; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: none; border-radius: 999px; cursor: pointer; }
.lightbox button:hover { background: rgba(255,255,255,.25); }
.lightbox-close { top: .6rem; right: .8rem; width: 2.6rem; height: 2.6rem; font-size: 1.2rem; }
.lightbox-prev, .lightbox-next { top: 50%; transform: translateY(-50%); width: 3rem; height: 3rem; font-size: 2rem; line-height: 1; }
.lightbox-prev { left: .6rem; }
.lightbox-next { right: .6rem; }
.lightbox.single .lightbox-prev, .lightbox.single .lightbox-next { display: none; }
@media (max-width: 640px) { .lightbox-prev, .lightbox-next { width: 2.4rem; height: 2.4rem; font-size: 1.6rem; background: rgba(0,0,0,.35); } }

/* Líneas de tiempo (floración / frutos) */
.timeline { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem; }
.timeline-row { display: grid; grid-template-columns: minmax(110px, 220px) repeat(12, 1fr); align-items: center; min-height: 1.9rem; border-bottom: 1px solid var(--border); }
.timeline-row:last-child { border-bottom: none; }
.timeline-head { min-height: 1.4rem; border-bottom: none; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.timeline-season { text-align: center; border-left: 1px solid var(--border); }
.timeline-month { text-align: center; }
.timeline-month.current { color: var(--accent-strong); font-weight: 700; }
.timeline-label { padding-right: .5rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.timeline-label small { display: block; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-track { grid-column: 2 / span 12; display: grid; grid-template-columns: repeat(12, 1fr); height: 1.9rem; align-items: center; }
.timeline-cell { grid-row: 1; height: 100%; border-left: 1px dashed var(--border); }
.timeline-cell.current { background: var(--accent-soft); }
.timeline-bar { grid-row: 1; height: .9rem; border-radius: 999px; margin: 0 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.timeline-missing { margin-top: .4rem; }
.timeline-bar.approx { opacity: .45; }
.timeline-subheading { margin: 1.5rem 0 .5rem; font-size: 1rem; }
.timeline-label:has(.timeline-edit) { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: .3rem; align-items: baseline; }
.timeline-label:has(.timeline-edit) small { grid-column: 2; }
.timeline-edit { color: var(--muted); font-size: .85rem; padding: 0; }
.timeline-editor { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; padding: .5rem .25rem .7rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.timeline-editor[hidden] { display: none; }
.month-picker { display: flex; flex-wrap: wrap; gap: .2rem .6rem; }
.month-picker label { display: inline-flex; gap: .2rem; align-items: center; font-weight: 400; font-size: .85rem; margin: 0; }
.month-picker input { width: auto; margin: 0; }
.timeline-season .short { display: none; }
@media (max-width: 640px) {
  .timeline { padding: .4rem .5rem; overflow-x: auto; }
  .timeline-row { grid-template-columns: 105px repeat(12, minmax(18px, 1fr)); }
  .timeline-label { font-size: .85rem; }
  .timeline-season .long { display: none; }
  .timeline-season .short { display: inline; }
}

/* Wish list */
.wish { display: flex; gap: .4rem; align-items: center; flex-wrap: nowrap; }
.wish form { display: inline; }
.badge-had { background: var(--danger-soft); color: var(--danger); }
.badge-rejected { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.rejection { margin: 1rem 0; }
.rejection summary { cursor: pointer; color: var(--muted); }
.rejection .reasons { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: .5rem 0; }
.rejection .reasons label { font-weight: 400; display: inline-flex; gap: .3rem; align-items: center; }
.rejection-box { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.wish .wish-on { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.wish .wish-off { white-space: nowrap; }

.note p { margin: 0 0 .5rem; }
.note .meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.note-count { font-size: .8rem; color: var(--muted); }

/* Calendar */
.task { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: none; }
.task form { display: inline; }
.task .check { width: 1.6rem; height: 1.6rem; padding: 0; justify-content: center; border-radius: 6px; flex: none; }
.task.done .check { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.task.done .description { color: var(--muted); text-decoration: line-through; }
.task .body { flex: 1; }
.task .meta { font-size: .8rem; color: var(--muted); }

.empty { color: var(--muted); padding: 1rem 0; }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  td.num small { display: block; }
  th, td { padding: .45rem .5rem; }
}

/* ---------- Celular ---------- */
.tabbar { display: none; }

@media (max-width: 800px) {
  .topbar { display: none; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .container { padding-top: .9rem; }

  .tabbar {
    display: flex; position: fixed; z-index: 2000; left: 0; right: 0; bottom: 0;
    padding: 0 4px env(safe-area-inset-bottom); background: var(--surface);
    border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(0,0,0,.06);
  }
  .tabbar .tab, .tab-more > summary {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 58px; color: var(--muted); font-size: .72rem; text-decoration: none; list-style: none; cursor: pointer;
  }
  .tab-more { flex: 1; display: flex; }
  .tab-more > summary::-webkit-details-marker { display: none; }
  .tabbar .tab.active, .tab-more > summary.active, .tab-more[open] > summary { color: var(--accent-strong); font-weight: 600; }
  .tabbar .tab:hover { text-decoration: none; }
  .tab-more-panel {
    position: fixed; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); min-width: 200px;
    display: flex; flex-direction: column; padding: .35rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,.18);
  }
  .tab-more-panel a, .tab-more-panel .link-button { padding: .7rem .9rem; border-radius: 8px; color: var(--text); text-align: left; font-size: 1rem; }
  .tab-more-panel a:hover { background: var(--surface-2); text-decoration: none; }
  .tab-more-panel form { display: block; }
  .tab-more-panel .link-button { width: 100%; color: var(--danger); }
}

@media (max-width: 640px) {
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.05rem; }
  .page-header { gap: .5rem; margin-bottom: .75rem; }
  /* Acciones en una sola fila que se desliza de costado. */
  .page-header .actions { width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .page-header .actions::-webkit-scrollbar { display: none; }
  .page-header .actions > *, .page-header .actions .button { flex: none; white-space: nowrap; }
  .page-header .actions .button { padding: .4rem .7rem; font-size: .9rem; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: none; white-space: nowrap; }
  .filters input[type=search] { flex: 1 1 100%; width: 100%; }
  .card { padding: .8rem; }

  /* Tablas como tarjetas: nombre arriba y cada dato con su etiqueta. */
  .table-wrap { border: none; background: none; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .55rem .8rem; margin-bottom: .5rem; }
  .table-wrap td, .table-wrap td.hide-sm { display: block; padding: .2rem 0; border: none; text-align: right; overflow: hidden; }
  .table-wrap td::before { content: attr(data-label); float: left; margin-right: .75rem; padding-top: .1rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; text-align: left; }
  .table-wrap td br { display: none; }
  .table-wrap td small { margin-left: .3rem; }
  .table-wrap td[data-empty] { display: none; }
  .details { grid-template-columns: 1fr 1fr; gap: .6rem .9rem; }
  .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td:first-child { display: block; text-align: left; font-size: 1rem; padding-bottom: .35rem; margin-bottom: .2rem; border-bottom: 1px solid var(--border); }
  .table-wrap td:first-child::before { display: none; }
  .table-wrap td:empty { display: none; }
  td.num small { display: inline; }
  select.mobile-sort { display: block; margin: 0 0 .5rem auto; width: auto; font-size: .9rem; }
}
.mobile-sort { display: none; }

/* Filtros plegables (en celular se pliegan; en pantallas anchas siempre abiertos). */
.filter-panel > summary { list-style: none; cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); margin-bottom: .5rem; }
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary .count { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 .45rem; font-size: .8rem; font-weight: 700; }
@media (min-width: 801px) { .filter-panel > summary { display: none; } }

/* Etiquetas QR (plants#labels): siempre blanco y negro, como salen impresas. Medidas en cm para imprimir a escala. */
.qr-labels { display: flex; flex-wrap: wrap; gap: .4cm; margin-top: 1rem; }
.qr-label {
  position: relative; box-sizing: border-box; width: 6cm; min-height: 8.5cm; padding: .3cm;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: #fff; color: #000; border: 1px dashed #999; border-radius: 4px;
  break-inside: avoid; page-break-inside: avoid;
}
.qr-label svg { width: 5.2cm; height: 5.2cm; display: block; }
.qr-label-name { font-weight: 700; font-size: 13pt; line-height: 1.15; margin-top: .1cm; }
.qr-label-sci { font-style: italic; font-size: 10pt; margin-top: .05cm; }
.qr-label-url { font-size: 7pt; color: #444; margin-top: auto; padding-top: .1cm; word-break: break-all; }
.qr-label-download { position: absolute; top: .1cm; right: .15cm; font-size: .75rem; }
.qr-labels-small .qr-label { width: 4cm; min-height: 6cm; padding: .2cm; }
.qr-labels-small .qr-label svg { width: 3.6cm; height: 3.6cm; }
.qr-labels-small .qr-label-name { font-size: 10pt; }
.qr-labels-small .qr-label-sci { font-size: 8pt; }
.qr-labels-small .qr-label-url { font-size: 5.5pt; }

@media print {
  .topbar, .tabbar, .flash, .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  .container { max-width: none; padding: 0; }
  .qr-labels { margin: 0; }
  @page { margin: 1cm; }
}

/* Portada: nativización y plantas por tipo */
.nativization-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .5rem 1rem; }
.nativization-head h2 { margin: 0; }
.nativization-head p { margin: .25rem 0 0; }
.nativization-total { font-size: 2.6rem; font-weight: 700; line-height: 1; color: var(--accent-strong); }
.goal-bar { position: relative; height: 1rem; margin: 1rem 0 2rem; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.goal-bar-fill { height: 100%; border-radius: inherit; background: var(--accent); }
.goal-mark { position: absolute; top: -.25rem; bottom: -.25rem; width: 2px; background: var(--muted); }
.goal-mark.reached { background: var(--accent-strong); }
.goal-mark > span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: .2rem; font-size: .75rem; color: var(--muted); white-space: nowrap; }
.goal-mark:last-child > span { left: auto; right: 0; transform: none; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.type-grid .card + .card { margin-top: 0; }
.type-card header { display: flex; align-items: center; gap: .6rem; }
.type-card h3 { margin: 0; font-size: 1.05rem; flex: 1; }
.type-total { font-size: 1.6rem; font-weight: 700; }
.type-card p { margin: .5rem 0 0; font-size: .9rem; }
.icon-row { display: inline-flex; gap: .15rem; vertical-align: middle; }
.ui-icon { display: inline-block; width: 1.25rem; height: 1.25rem; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.icon-row.water .ui-icon { width: 1rem; margin-right: -.2rem; }
.light-full-sun { color: #e0a100; }
.light-partial-shade { color: #b0894a; }
.light-shade { color: #7d8894; }
.icon-row.water { color: #3b84c4; }
.ui-icon.off { opacity: .2; }
.env-espinal { color: #a07a2c; }
.env-pastizal { color: #7f9a2a; }
.env-selva-riberena { color: #2f7a3e; }
.env-humedal { color: #2f7fbf; }
.env-labels { flex-wrap: wrap; gap: .2rem .75rem; }
.env-label { display: inline-flex; align-items: center; gap: .25rem; }
.type-icon { position: relative; flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--accent-soft); }
.type-icon::after {
  content: ""; position: absolute; inset: .45rem; background: var(--accent-strong);
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.goal-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.goal-list li { display: grid; grid-template-columns: 4.5rem 4rem 1fr; gap: .25rem .75rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.goal-list li > strong small { display: block; font-weight: 400; font-size: .75rem; }
.goal-list .goal-list-head { padding: .3rem 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.goal-percent { color: var(--muted); }
.goal-percent small { display: block; font-size: .72rem; }
.goal-list .past .goal-percent { color: var(--accent-strong); font-weight: 700; }
/* La fila del año en curso separa lo que pasó de las metas. */
.goal-list .past:has(+ .goal) { border-bottom: 2px solid var(--accent); }
.incorp { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; }
.incorp-track { flex: none; width: 9rem; }
.incorp-bar { display: flex; height: .8rem; border-radius: 4px; overflow: hidden; }
.incorp-counts { font-size: .9rem; }
.incorp-counts > span { white-space: nowrap; }
.goal-note { margin: .6rem 0 0; font-size: .85rem; }
.incorp-legend { display: inline-flex; align-items: center; gap: .35rem; margin-right: .5rem; white-space: nowrap; }
.incorp-legend > span { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; }
.incorp-legend > span + span { margin-left: .4rem; }
.swatch-native { background: var(--accent); }
.swatch-exotic { background: var(--warn); }
@media (max-width: 640px) {
  /* Metas muy cercanas (50/60 % y 90/100 %): las etiquetas de 2028 y 2030 van arriba de la barra. */
  .goal-bar { margin-top: 2rem; }
  .goal-mark:nth-of-type(2) > span, .goal-mark:nth-of-type(4) > span { top: auto; bottom: 100%; margin: 0 0 .2rem; }
}
.type-progress { display: flex; align-items: center; gap: .6rem; margin-top: .75rem; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.type-bar { flex: 1; height: .45rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.type-bar > span { display: block; height: 100%; background: var(--accent); }
