/* ---------- Trazabilidad (modules/traceability.js) ---------- */
.tr-tabs { margin-bottom: 14px; }
.tr-note { color: var(--text3); font-size: 12.5px; margin: 10px 0 0; }
.tr-empty { color: var(--text3); font-size: 13.5px; margin: 0; padding: 4px 20px 18px; }

/* Search: one field, results under it, arrow keys move */
.tr-search { position: relative; padding: 14px; margin-bottom: 16px; }
.tr-search-input { display: flex; width: 100%; }
.tr-search-input input { width: 100%; height: 42px; font-size: 15px; }
.tr-results { position: absolute; left: 14px; right: 14px; top: calc(100% - 8px); z-index: 30; list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto; }
.tr-results li { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 0 12px; padding: 9px 10px; border-radius: var(--r-md); cursor: pointer; }
.tr-results li b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-results li .tr-res-kind { grid-row: 1 / span 2; color: var(--text3); font-size: 12px; padding-top: 2px; }
.tr-results li .tr-res-sub { grid-column: 2; color: var(--text3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-results li[aria-selected="true"], .tr-results li:hover { background: var(--hover-strong); }
.tr-results li.tr-res-empty { display: block; color: var(--text3); cursor: default; background: none; }

.tr-start p { margin: 0 0 8px; color: var(--text2); max-width: 70ch; line-height: 1.55; }
.tr-flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tr-flow span { font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 999px; background: var(--surface-3); }
.tr-flow svg { width: 14px; height: 14px; color: var(--text3); }

/* Head of the chain */
.tr-head { margin-bottom: 16px; }
.tr-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.tr-head .eyebrow { margin-bottom: 4px; }
.tr-title { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.tr-title-sub { color: var(--text3); font-weight: 400; }
.tr-head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tr-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 20px; margin: 18px 0 0; }
.tr-facts div { min-width: 0; }
.tr-facts dt { font-size: 12px; color: var(--text3); margin-bottom: 2px; }
.tr-facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tr-steps { display: flex; flex-direction: column; gap: 16px; }
.tr-step .card-h { padding: 16px 20px 10px; }
.tr-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.tr-link:hover { text-decoration-color: currentColor; }
.tr-loading { display: flex; flex-direction: column; gap: 10px; }
.tr-loading .skel { height: 14px; }
.tr-loading .skel:first-child { width: 40%; height: 20px; }

/* Recall drill */
#trRecall:not(:empty) { margin-top: 16px; }
.tr-recall .card-h { padding: 16px 20px 6px; }
.tr-recall-sum { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; padding: 6px 20px 16px; border-bottom: 1px solid var(--border); }
.tr-recall-sum > div:not(.tr-recall-actions) { display: flex; align-items: baseline; gap: 8px; }
.tr-recall-sum b { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.tr-recall-sum span { color: var(--text2); font-size: 13px; }
.tr-recall-actions { margin-left: auto; display: flex; gap: 8px; }

/* Recipes */
.tr-brew-new { margin-bottom: 16px; padding: 22px 20px 16px; }
.tr-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.tr-form .field { flex: 1 1 140px; margin: 0; }
.tr-form .tr-wide { flex: 2 1 220px; }
.tr-form .tr-small { flex: 0 1 108px; }
.tr-form input { font-variant-numeric: tabular-nums; }

/* Producer stories */
.tr-stories { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; }
.tr-pick { cursor: pointer; }
.tr-pick.is-active td { background: var(--accent-soft); }
.tr-pick.is-active td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.tr-story-edit .field { display: block; margin-bottom: 14px; }
.tr-story-edit textarea { width: 100%; resize: vertical; min-height: 140px; line-height: 1.5; }
.tr-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tr-photos figure { position: relative; margin: 0; }
.tr-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-md); display: block; background: var(--surface-3); }
.tr-photos figcaption { font-size: 12px; color: var(--text3); margin-top: 4px; }
.tr-photos .st-del { position: absolute; top: 6px; right: 6px; background: var(--surface); box-shadow: var(--shadow-sm); }
.tr-photo-add { aspect-ratio: 4 / 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px dashed var(--border-strong); border-radius: var(--r-md); cursor: pointer; color: var(--text2); font-size: 13px; text-align: center; padding: 8px; }
.tr-photo-add:hover { background: var(--hover); }
.tr-photo-add:focus-within { box-shadow: var(--ring); }
.tr-photo-add svg { width: 18px; height: 18px; }
.tr-photo-add small { color: var(--text3); font-size: 11.5px; }
.tr-photo-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tr-story-actions { display: flex; justify-content: flex-end; }

/* Scans and ratings */
.tr-qr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.tr-kpi .k { font-size: 12.5px; color: var(--text3); }
.tr-kpi .v { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.tr-kpi .v .unit { font-size: 14px; font-weight: 400; color: var(--text3); margin-left: 4px; }
.tr-kpi .s { font-size: 12.5px; color: var(--text3); }
.tr-qr-grid + .card, #qrBody > .card { margin-bottom: 16px; }
.tr-bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.tr-bars span { flex: 1; height: max(2px, var(--h)); background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; }
.tr-bars span:hover { opacity: 1; }
.tr-bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--text3); margin-top: 6px; }
.tr-stars { color: var(--signal); letter-spacing: 1px; white-space: nowrap; }
.tr-star-off { color: var(--border-strong); }
tr.is-hidden td { opacity: .5; }

/* From Café verde → Lotes */
.tr-lot-link { margin-left: 6px; vertical-align: middle; }
.tr-lot-link svg { width: 14px; height: 14px; }

@media (max-width: 860px) {
  .tr-stories { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .tr-results li { grid-template-columns: 1fr; }
  .tr-results li .tr-res-kind { grid-row: auto; }
  .tr-results li .tr-res-sub { grid-column: 1; }
  .tr-title { font-size: 19px; }
  .tr-recall-sum { flex-direction: column; align-items: flex-start; gap: 6px; }
  .tr-recall-actions { margin-left: 0; margin-top: 8px; }
  .tr-form .tr-small { flex: 1 1 calc(50% - 6px); }
}
