/* EucaTool 2.0 — paleta tomada del propio eucalipto: canopia, hoja glauca y corteza */
:root {
  --paper: #F3F5F2;
  --surface: #FFFFFF;
  --ink: #1F2A2E;
  --muted: #5B6B66;
  --line: #D6DDD8;
  --canopy: #2F5D50;
  --canopy-ink: #FFFFFF;
  --leaf: #7FA3A0;
  --leaf-soft: #E3ECEA;
  --bark: #C7A57A;
  --bark-soft: #F4EBDD;
  --danger: #B4432F;
  --danger-soft: #F8E6E1;

  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L", Georgia, serif;
  --sans: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r-s: 6px;
  --r-m: 12px;
  --gap: clamp(16px, 2.5vw, 28px);
  --maxw: 1240px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #121817;
  --surface: #1A2321;
  --ink: #E4EBE8;
  --muted: #98A9A3;
  --line: #2C3835;
  --canopy: #8CC0AE;
  --canopy-ink: #10201B;
  --leaf: #6F9692;
  --leaf-soft: #20302D;
  --bark: #D9B88A;
  --bark-soft: #2E2A22;
  --danger: #E38B76;
  --danger-soft: #3A2420;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--canopy); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; max-width: 72ch; }
:focus-visible { outline: 3px solid var(--bark); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top__in { max-width: var(--maxw); margin: 0 auto; padding: 10px var(--gap); display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand svg { width: 30px; height: 30px; }
.brand span { font-family: var(--serif); font-size: 1.45rem; letter-spacing: .01em; }
.brand sup { font-size: .55em; color: var(--muted); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: var(--r-s); font-weight: 500; white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--leaf-soft); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--canopy); border-radius: 0; }
.nav .nav__sep { width: 1px; background: var(--line); margin: 6px 8px; }
.tools { display: flex; align-items: center; gap: 8px; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang button { border: 0; background: none; color: var(--muted); font: 600 .78rem var(--sans); padding: 4px 9px; border-radius: 999px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--canopy); color: var(--canopy-ink); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

/* ---------- Estructura ---------- */
main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: var(--gap); }
.page-head { margin: 8px 0 24px; }
.page-head p { color: var(--muted); }

/* ---------- Portada ---------- */
.hero { position: relative; padding: clamp(24px, 6vw, 72px) 0 0; }
.hero h1 { max-width: 18ch; }
.hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 54ch; }
.hero__treeline { color: var(--leaf); margin-top: 24px; width: 100%; height: auto; }
.entries { border-top: 1px solid var(--ink); }
.entry {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px 32px; align-items: baseline;
  padding: 22px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.entry__name { font-family: var(--serif); font-size: clamp(1.4rem, 2.8vw, 2.1rem); }
.entry__desc { color: var(--muted); margin: 0; }
.entry__unit { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.entry:hover .entry__name { color: var(--canopy); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.note { font-size: .92rem; color: var(--muted); margin-top: 20px; }

/* ---------- Herramientas ---------- */
.tool { display: grid; grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 20px; }
.panel--sticky { position: sticky; top: 76px; }
.panel h2 { font-size: 1.25rem; }
.field { display: grid; gap: 4px; margin-bottom: 14px; align-content: start; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .8rem; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.field-row--3 { grid-template-columns: .8fr 1fr 1fr; }
input[type="text"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-s); padding: 9px 10px;
}
input[type="text"]:focus, textarea:focus { outline: 2px solid var(--canopy); outline-offset: 0; border-color: transparent; }
input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.with-btn { display: flex; gap: 6px; }
.with-btn input { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 .92rem var(--sans); padding: 9px 16px; border-radius: var(--r-s); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none;
}
.btn:hover { border-color: var(--leaf); }
.btn--primary { background: var(--canopy); border-color: var(--canopy); color: var(--canopy-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--block { width: 100%; }
.btn--danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-s); padding: 3px; margin-bottom: 16px; }
.segmented button { border: 0; background: none; padding: 7px; border-radius: 4px; font: 600 .88rem var(--sans); color: var(--muted); cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.radio { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: .92rem; cursor: pointer; }
.radio input { margin-top: 4px; accent-color: var(--canopy); }
.file { display: inline-flex; }
.file input { position: absolute; opacity: 0; width: 1px; }

/* Resumen */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); margin-bottom: 16px; }
.summary > div { padding: 14px 18px; border-left: 1px solid var(--line); }
.summary > div:first-child { border-left: 0; }
.summary dt { font-size: .82rem; color: var(--muted); }
.summary dd { margin: 2px 0 0; font-family: var(--serif); font-size: clamp(1.3rem, 2.4vw, 1.8rem); }
.summary small { font-family: var(--sans); font-size: .8rem; color: var(--muted); margin-left: 4px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions .spacer { flex: 1; }

/* Tablas */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; background: var(--surface); font-weight: 600; z-index: 1; vertical-align: bottom; }
th abbr { text-decoration: none; cursor: help; }
th .u { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }
td:first-child, th:first-child { text-align: left; }
tbody tr:hover { background: var(--leaf-soft); }
tbody tr:last-child td { border-bottom: 0; }
td.est { color: var(--muted); font-style: italic; }
td.warn { color: var(--danger); }
tr.is-turno { background: var(--bark-soft); }
tr.is-turno td { font-weight: 600; }
tr.is-turno td:first-child { box-shadow: inset 4px 0 0 var(--bark); }
tr.is-ref td:first-child::after { content: " IS"; font-size: .7rem; color: var(--muted); }
input[type="checkbox"] { accent-color: var(--canopy); width: 16px; height: 16px; }

.empty { border: 1px dashed var(--line); border-radius: var(--r-m); padding: 40px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 64px; margin: 0 auto 12px; color: var(--leaf); }

.alert { border-radius: var(--r-s); padding: 10px 14px; margin: 12px 0; font-size: .92rem; background: var(--bark-soft); border-left: 4px solid var(--bark); }
.alert--error { background: var(--danger-soft); border-left-color: var(--danger); }

/* ---------- Rodal ---------- */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--ink); margin-bottom: 24px; }
.fact { padding: 16px 20px 16px 0; }
.fact + .fact { padding-left: 20px; border-left: 1px solid var(--line); }
.fact dt { color: var(--muted); font-size: .88rem; }
.fact dd { margin: 4px 0 0; font-family: var(--serif); font-size: clamp(1.6rem, 3.4vw, 2.6rem); line-height: 1.1; }
.fact dd small { font-family: var(--sans); font-size: .85rem; color: var(--muted); display: block; margin-top: 4px; line-height: 1.4; }
.fact--turno dd { color: var(--ink); }
.fact--turno dd b { font-weight: 600; box-shadow: inset 0 -.28em 0 var(--bark); }

.chart { margin: 0 0 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px 16px 8px; margin-bottom: 24px; }
.chart__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; align-items: baseline; margin-bottom: 6px; }
.chart__head h3 { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font: 11px var(--sans); fill: var(--muted); }
.chart .axis { stroke: var(--line); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .vol { fill: color-mix(in srgb, var(--leaf) 28%, transparent); stroke: var(--leaf); stroke-width: 2; }
.chart .cm { fill: none; stroke: var(--canopy); stroke-width: 2.5; }
.chart .cc { fill: none; stroke: var(--bark); stroke-width: 2.5; }
.chart .turno { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 4 3; }
.chart .turno-label { fill: var(--ink); font-weight: 600; }
.chart .dot { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.chart .hover-line { stroke: var(--muted); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: .8rem; padding: 6px 9px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%); }
.chart-box { position: relative; }

.legend-text { font-size: .86rem; color: var(--muted); }
.legend-text b { color: var(--ink); }

/* ---------- Páginas de texto ---------- */
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.6em; }
.prose p { font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; }
dl.gloss { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 0; border-top: 1px solid var(--ink); }
dl.gloss dt, dl.gloss dd { padding: 14px 0; border-bottom: 1px solid var(--line); margin: 0; }
dl.gloss dt { font-family: var(--serif); font-weight: 600; padding-right: 16px; }
dl.gloss dd p { margin: 0 0 .4em; }
.news { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--ink); max-width: 860px; }
.news li { border-bottom: 1px solid var(--line); }
.news a { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; padding: 16px 0; text-decoration: none; color: var(--ink); }
.news strong { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.news span { color: var(--muted); font-size: .88rem; }
.news a:hover strong { color: var(--canopy); text-decoration: underline; }
.contact { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }
.contact h2 { font-size: 1.2rem; }
.contact p { margin: 0 0 .4em; }
.contact .k { color: var(--muted); font-size: .88rem; display: block; }
table.simple { width: auto; margin: 8px 0 16px; }
table.simple th { position: static; }

/* ---------- Pie ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 48px; padding: 28px var(--gap) 96px; color: var(--muted); font-size: .8rem; }
.foot__in { max-width: var(--maxw); margin: 0 auto; }
.logos { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: center; margin-bottom: 18px; }
.logos img { height: 44px; width: auto; background: #fff; padding: 4px; border-radius: 4px; }
.foot p { max-width: 110ch; }

/* ---------- Barra inferior móvil ---------- */
.tabbar { display: none; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: .9rem; z-index: 60; display: flex; gap: 12px; align-items: center; }
.toast button { background: none; border: 0; color: var(--bark); font: 600 .9rem var(--sans); cursor: pointer; }
.loading { opacity: .55; transition: opacity .2s; }

@media (max-width: 980px) {
  .tool { grid-template-columns: minmax(0, 1fr); }
  .panel--sticky { position: static; }
  .nav { display: none; }
  .nav.open { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px var(--gap) 16px; }
  .nav.open .nav__sep { width: auto; height: 1px; margin: 6px 0; }
  .menu-btn { display: grid; }
  .top__in { justify-content: space-between; }
  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .75rem; font-weight: 600; padding: 4px; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--canopy); }
}
@media (max-width: 640px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .summary > div:nth-child(3) { border-left: 0; }
  .summary > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .facts { grid-template-columns: 1fr; }
  .fact + .fact { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .entry { grid-template-columns: 1fr; }
  dl.gloss { grid-template-columns: 1fr; }
  dl.gloss dt { border-bottom: 0; padding-bottom: 0; }
  .news a { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .hero__treeline path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.2s ease-out .1s forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}

/* ---------- Impresión del informe ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  :root { --paper: #fff; --surface: #fff; --ink: #000; --line: #bbb; --muted: #444; }
  body { font-size: 10pt; background: #fff; }
  .top, .tabbar, .foot, .panel, .actions, .no-print, .toast, .skip { display: none !important; }
  .tool { display: block; }
  main { padding: 0; max-width: none; }
  .print-only { display: block; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .print-head img { width: 90px; height: 90px; }
  .print-head .url { font-size: 7pt; color: #444; max-width: 90px; word-break: break-all; }
  .table-wrap { max-height: none; overflow: visible; border: 0; }
  th { position: static; }
  .chart, .facts, table { break-inside: avoid; }
  tr.is-turno { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
