:root {
  --ink: #2a1f17; --muted: #7a6a5a; --line: #e8dfcf; --line-strong: #d6c7ae;
  --canvas: #f4eee2; --surface: #fffdf8;
  --wood-950: #24180f; --wood-900: #33231a; --wood-800: #4a3222; --wood-600: #8a5a35; --wood-100: #f3e7d6;
  --pasture: #4f6f35; --pasture-soft: #e6eed8; --ochre: #c88a14; --ochre-soft: #fbefcf; --tag: #f2c230;
  --terra: #b5542d; --terra-dark: #93401f; --terra-soft: #f8e2d7; --red: #a33b2b; --red-soft: #f9e1dc;
  --blue: #3f6b84; --blue-soft: #e3edf2;
  --slab: "Rockwell", "Roboto Slab", "Zilla Slab", "Georgia", serif;
  --radius: 10px; --shadow: 0 18px 44px rgba(52,33,18,.16); --shadow-soft: 0 2px 0 rgba(90,60,30,.06), 0 8px 20px rgba(90,60,30,.06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink); font-size: 15px; line-height: 1.45; padding-top: 30px;
  background: var(--canvas) radial-gradient(rgba(138,90,53,.07) 1px, transparent 1.2px) 0 0 / 14px 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--slab); font-weight: 700; letter-spacing: -.01em; }

/* ---------- franja demo ---------- */
.demo-strip { position: fixed; inset: 0 0 auto 0; height: 30px; z-index: 60; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--tag); color: var(--wood-950); font-size: .76rem; font-weight: 700; }
.demo-strip .tag { padding: 2px 8px; border-radius: 4px; background: var(--wood-950); color: var(--tag); font-size: .66rem; font-weight: 900; letter-spacing: .12em; }
.demo-strip .txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-strip button { padding: 3px 11px; border: 1.5px solid var(--wood-950); border-radius: 4px; background: transparent; color: var(--wood-950); font-size: .72rem; font-weight: 800; }

/* ---------- cabecera con navegación superior ---------- */
.ranch-header { position: sticky; top: 30px; z-index: 30; color: #f4e9d8; background: var(--wood-950) repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 2px, transparent 2px 9px); border-bottom: 4px solid var(--terra); box-shadow: 0 6px 18px rgba(36,24,15,.25); }
.rh-top { display: flex; align-items: center; gap: 22px; padding: 10px 26px; }
.brand { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--tag); color: var(--wood-950); border: 3px solid #fff3c9; }
.brand strong { display: block; font-family: var(--slab); font-size: 1.15rem; letter-spacing: .02em; }
.brand span { display: block; color: #cdb99c; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.group-tabs { display: flex; gap: 4px; margin-left: 10px; flex: 1; min-width: 0; }
.group-tab { display: flex; align-items: center; gap: 8px; padding: 9px 16px; border: 0; border-radius: 8px 8px 0 0; background: transparent; color: #d9c6a8; font-family: var(--slab); font-weight: 700; font-size: .98rem; position: relative; top: 11px; padding-bottom: 20px; }
.group-tab:hover { color: #fff; background: rgba(255,255,255,.05); }
.group-tab.active { color: var(--wood-950); background: var(--canvas); }
.group-tab .gcount { min-width: 20px; height: 19px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--terra); color: #fff; font-family: "Segoe UI", sans-serif; font-size: .64rem; font-weight: 900; }
.group-tab .gcount:empty { display: none; }
.top-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.sede-select { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; background: rgba(255,255,255,.06); font-size: .74rem; font-weight: 800; color: #cdb99c; text-transform: uppercase; letter-spacing: .06em; }
.sede-select select { border: 0; background: var(--tag); border-radius: 6px; padding: 6px 8px; font-weight: 800; color: var(--wood-950); text-transform: none; letter-spacing: 0; }
.sub-tabs { display: flex; gap: 2px; padding: 0 26px; background: var(--canvas); border-bottom: 1px solid var(--line-strong); overflow-x: auto; scrollbar-width: thin; }
.sub-tab { display: flex; align-items: center; gap: 7px; padding: 12px 14px 10px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 700; font-size: .87rem; white-space: nowrap; }
.sub-tab:hover { color: var(--ink); }
.sub-tab.active { color: var(--terra-dark); border-bottom-color: var(--terra); }
.nav-count { min-width: 20px; height: 18px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--wood-100); color: var(--wood-800); font-size: .64rem; font-weight: 900; }
.nav-count.risk { background: var(--terra); color: #fff; }
.nav-count:empty { display: none; }

.page-title-row { max-width: 1640px; margin: 0 auto; display: flex; align-items: flex-end; gap: 16px; padding: 22px 26px 0; }
.page-heading { margin-right: auto; min-width: 0; }
.eyebrow, .page-heading p { margin: 0 0 3px; color: var(--terra); font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.page-heading h1 { margin: 0; font-size: 1.85rem; color: var(--wood-900); }

/* ---------- botones ---------- */
.button { min-height: 40px; padding: 8px 15px; border: 1.5px solid transparent; border-radius: 8px; font-weight: 750; transition: .14s; display: inline-flex; align-items: center; gap: 7px; justify-content: center; text-decoration: none; white-space: nowrap; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--terra); color: #fff; box-shadow: 0 3px 0 var(--terra-dark); }
.button.primary:hover { background: var(--terra-dark); }
.button.primary:active { transform: translateY(2px); box-shadow: none; }
.button.secondary { background: var(--surface); color: var(--wood-800); border-color: var(--line-strong); }
.button.lime { background: var(--tag); color: var(--wood-950); box-shadow: 0 3px 0 #b58d12; }
.button.glass { background: rgba(255,255,255,.08); color: #f4e9d8; border-color: rgba(255,255,255,.25); }
.button.danger { background: var(--red); color: #fff; }
.button.small { min-height: 32px; padding: 5px 10px; font-size: .8rem; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 1.2rem; }

main { max-width: 1640px; margin: 0 auto; padding: 18px 26px 56px; }
.view { display: grid; gap: 18px; }

/* ---------- paneles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--wood-600); border-radius: var(--radius); box-shadow: var(--shadow-soft); overflow: hidden; min-width: 0; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; padding: 15px 18px 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 2px 0 0; font-size: 1.15rem; color: var(--wood-900); }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; max-width: 780px; }
.panel-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 0 18px 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.35fr); gap: 18px; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* ---------- parte diario (resumen) ---------- */
.parte { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 24px; align-items: center; padding: 22px 26px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface) repeating-linear-gradient(180deg, transparent 0 31px, rgba(181,84,45,.10) 31px 32px); box-shadow: var(--shadow-soft); position: relative; overflow: hidden; }
.parte::before { content: ""; position: absolute; left: 70px; top: 0; bottom: 0; width: 2px; background: rgba(181,84,45,.25); }
.parte-date { display: flex; gap: 18px; align-items: center; padding-left: 70px; }
.parte-day { position: absolute; left: 12px; top: 20px; width: 46px; text-align: center; font-family: var(--slab); }
.parte-day b { display: block; font-size: 1.9rem; line-height: 1; color: var(--terra); }
.parte-day small { display: block; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.parte h2 { margin: 0; font-size: 1.7rem; color: var(--wood-900); }
.parte p { margin: 4px 0 0; color: var(--muted); }
.parte-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 12px; }
.parte-stats div { font-size: .8rem; color: var(--muted); }
.parte-stats strong { display: block; font-family: var(--slab); font-size: 1.35rem; color: var(--ink); }
.parte-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.stamp { position: absolute; right: 250px; top: 16px; padding: 6px 12px; border: 3px double var(--terra); border-radius: 6px; color: var(--terra); font-family: var(--slab); font-weight: 700; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; transform: rotate(-8deg); opacity: .55; }

/* ---------- fichas (métricas) ---------- */
.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; }
.metric { position: relative; padding: 14px 16px 14px 18px; border: 1px solid var(--line); border-left: 6px solid var(--pasture); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-soft); text-align: left; min-width: 0; }
button.metric { cursor: pointer; transition: .15s; }
button.metric:hover { transform: translateY(-2px); }
.metric > span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding-right: 34px; }
.metric > strong { display: block; margin-top: 6px; font-family: var(--slab); font-size: 1.6rem; color: var(--wood-900); }
.metric > small { display: block; margin-top: 2px; color: var(--muted); font-size: .74rem; }
.metric.alert { border-left-color: var(--terra); background: linear-gradient(90deg, var(--terra-soft), var(--surface) 60%); }
.metric.good { border-left-color: var(--pasture); background: linear-gradient(90deg, var(--pasture-soft), var(--surface) 60%); }
.metric .ico { position: absolute; right: 12px; top: 12px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--wood-100); color: var(--wood-600); font-weight: 900; font-size: .8rem; font-style: normal; }
.metric.alert .ico { background: var(--terra); color: #fff; }

/* ---------- mapa de corrales ---------- */
.pen-sedes { display: grid; gap: 16px; padding: 0 18px 18px; }
.pen-sede h3 { margin: 0 0 8px; font-size: .95rem; color: var(--wood-800); display: flex; justify-content: space-between; align-items: center; }
.pen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px,1fr)); gap: 10px; }
.pen { position: relative; min-height: 104px; padding: 8px 10px; border: 3px solid var(--wood-600); border-radius: 4px; text-align: left; overflow: hidden; background: #f7f0de repeating-linear-gradient(90deg, transparent 0 24px, rgba(138,90,53,.14) 24px 27px); transition: .15s; }
.pen::before, .pen::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: rgba(138,90,53,.35); z-index: 1; }
.pen::before { top: 34%; }
.pen::after { top: 64%; }
.pen:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(90,60,30,.18); }
.pen > span { position: relative; z-index: 2; display: block; }
.pen-fill { position: absolute !important; left: 0; right: 0; bottom: 0; z-index: 0 !important; background: linear-gradient(180deg, rgba(122,160,74,.35), rgba(79,111,53,.55)); }
.pen-num { font-family: var(--slab); font-weight: 700; font-size: .78rem; color: var(--wood-600); letter-spacing: .08em; text-transform: uppercase; }
.pen-count { font-family: var(--slab); font-size: 1.55rem; font-weight: 700; color: var(--wood-950); line-height: 1.1; }
.pen-count small { font-size: .8rem; color: var(--muted); font-weight: 600; }
.pen-breed { font-size: .72rem; font-weight: 700; color: var(--wood-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pen-flag { position: absolute !important; top: 7px; right: 7px; padding: 1px 6px; border-radius: 4px; background: var(--terra); color: #fff; font-size: .62rem; font-weight: 900; }
.pen.empty { border-style: dashed; opacity: .7; }
.pen.over { border-color: var(--red); }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { padding: 9px 12px; border-block: 1px solid var(--line-strong); background: var(--wood-100); color: var(--wood-600); font-size: .68rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; text-align: left; }
.data-table td { padding: 9px 12px; border-bottom: 1px dashed #eadfcb; font-size: .85rem; vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: #fcf8f0; }
.data-table tbody tr:hover { background: var(--ochre-soft); }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.muted-row { opacity: .6; }
.data-table td.wrap { white-space: normal; min-width: 200px; max-width: 300px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.main { display: block; font-weight: 720; }
.sub { display: block; margin-top: 2px; color: var(--muted); font-size: .74rem; }
.inline-sub { color: var(--muted); font-size: .74rem; margin-left: 6px; }
.table-actions { display: flex; gap: 4px; }
.action-link { border: 0; background: transparent; color: var(--terra-dark); padding: 5px 7px; border-radius: 6px; font-size: .8rem; font-weight: 800; }
.action-link:hover { background: var(--terra-soft); }
.action-link.danger { color: var(--red); }
.cell-low { background: var(--red-soft) !important; color: var(--red); font-weight: 800; }
.col-hl { background: rgba(242,194,48,.16); }

/* arete amarillo para números de animal y códigos */
.tag-num { position: relative; display: inline-block; padding: 2px 9px 2px 17px; border-radius: 12px 12px 14px 14px / 9px 9px 14px 14px; background: var(--tag); color: #3a2a0a; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 800; font-size: .8rem; box-shadow: inset 0 -2px 0 rgba(0,0,0,.14); white-space: nowrap; }
.tag-num::before { content: ""; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--canvas); box-shadow: inset 0 1px 1px rgba(0,0,0,.35); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px; font-size: .7rem; font-weight: 800; letter-spacing: .02em; background: var(--wood-100); color: var(--wood-800); white-space: nowrap; }
.badge.ok { background: var(--pasture-soft); color: var(--pasture); }
.badge.warn { background: var(--ochre-soft); color: #8c5f07; }
.badge.risk { background: var(--red-soft); color: var(--red); }
.badge.info { background: var(--blue-soft); color: var(--blue); }
.badge.muted { background: #efe9df; color: var(--muted); }
.badge.leather { background: var(--wood-100); color: var(--wood-600); }
.badge.dark { background: var(--wood-950); color: #f4e9d8; }
.bar { position: relative; width: 96px; height: 8px; border-radius: 2px; background: #eadfcb; overflow: hidden; display: inline-block; vertical-align: middle; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--pasture); }
.bar.warn i { background: var(--ochre); }
.bar.risk i { background: var(--terra); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 0 18px 14px; }
.toolbar input, .toolbar select { min-height: 38px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.toolbar input[type=search] { min-width: 260px; flex: 1; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.hint { color: var(--muted); font-size: .8rem; }

.alert-list { display: grid; gap: 8px; padding: 0 18px 18px; }
.alert-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: 6px; background: var(--surface); text-align: left; width: 100%; }
.alert-item:hover { background: #fcf8f0; }
.alert-item.excedido { border-left-color: var(--terra); }
.alert-item.listo { border-left-color: var(--pasture); }
.alert-item.proximo { border-left-color: var(--ochre); }
.alert-item .ai-main { flex: 1; min-width: 0; }
.alert-item strong { display: block; font-size: .86rem; }
.alert-item small { display: block; color: var(--muted); font-size: .76rem; }
.feed { list-style: none; margin: 0; padding: 0 18px 18px; display: grid; gap: 10px; }
.feed li { display: flex; gap: 10px; align-items: flex-start; font-size: .84rem; }
.feed .fi { flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: var(--pasture-soft); color: var(--pasture); }
.feed .fi.risk { background: var(--terra-soft); color: var(--terra); }
.feed .fi.info { background: var(--blue-soft); color: var(--blue); }
.feed .fi.leather { background: var(--wood-100); color: var(--wood-600); }
.feed small { display: block; color: var(--muted); font-size: .72rem; }

.motivo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px,1fr)); gap: 10px; padding: 0 18px 18px; }
.motivo-card { padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fcf8f0; }
.motivo-card strong { display: block; font-family: var(--slab); font-size: 1.5rem; margin: 6px 0 2px; }
.motivo-card p { margin: 0; color: var(--muted); font-size: .76rem; }

.kv-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.kv { padding: 9px 12px; border-radius: 6px; background: #f8f1e4; border-left: 3px solid var(--wood-600); min-width: 0; }
.kv span { display: block; font-size: .66rem; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.kv strong { display: block; margin-top: 3px; font-size: .9rem; overflow-wrap: anywhere; }
.kv.full { grid-column: 1 / -1; }
.mt { margin-top: 14px; }

/* ---------- diálogos y formularios ---------- */
dialog { padding: 0; border: 0; border-radius: 10px; box-shadow: var(--shadow); width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 30px); color: var(--ink); background: var(--surface); }
dialog.wide { width: min(1120px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(36,24,15,.62); backdrop-filter: blur(2px); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 30px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 22px 13px; color: #f4e9d8; background: var(--wood-950); border-bottom: 4px solid var(--terra); }
.dialog-head .eyebrow { color: var(--tag); }
.dialog-head h2 { margin: 0; font-size: 1.28rem; }
.dialog-head .icon-button { background: transparent; color: #f4e9d8; border-color: rgba(255,255,255,.25); }
.dialog-body { padding: 18px 22px; overflow-y: auto; }
.dialog-error { margin: 0 22px 10px; padding: 9px 12px; border-radius: 6px; background: var(--red-soft); color: var(--red); font-weight: 700; font-size: .85rem; }
.dialog-error:empty { display: none; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: #faf5ea; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field { display: grid; gap: 5px; align-content: start; }
.full { grid-column: 1 / -1; }
.field > span { font-size: .72rem; font-weight: 800; color: var(--wood-800); letter-spacing: .04em; text-transform: uppercase; }
.field input, .field select, .field textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fffefb; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(181,84,45,.25); border-color: var(--terra); }
.field input.auto { background: var(--ochre-soft); font-weight: 900; color: #6d4a06; border: 2px dashed var(--ochre); }
.subgrid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px 14px; padding: 12px; border: 1.5px dashed var(--wood-600); border-radius: 8px; background: var(--wood-100); }
.subgrid .sg-title { grid-column: 1 / -1; font-size: .78rem; font-weight: 850; color: var(--wood-600); }
.preview { margin-top: 14px; padding: 12px 14px; border-radius: 8px; background: var(--pasture-soft); border-left: 4px solid var(--pasture); color: #2f4520; font-size: .86rem; display: grid; gap: 8px; }
.preview.bad { background: var(--red-soft); border-left-color: var(--red); color: var(--red); }
.preview .big { font-family: var(--slab); font-size: 1.12rem; }
.preview .warn-line { color: #8c5f07; font-weight: 700; }
.preview .err-line { color: var(--red); font-weight: 750; }
.corr-strip { display: flex; flex-wrap: wrap; gap: 5px; }
.corr-strip span { position: relative; padding: 2px 7px 2px 14px; border-radius: 10px 10px 12px 12px / 8px 8px 12px 12px; background: var(--tag); font-family: ui-monospace, Consolas, monospace; font-size: .72rem; font-weight: 800; color: #3a2a0a; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.corr-strip span::before { content: ""; position: absolute; left: 5px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: #fff; }
.corr-strip span.first, .corr-strip span.last { background: var(--terra); color: #fff; }
.inp-sel { min-height: 32px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fffefb; }
.inp-sm { width: 92px; min-height: 32px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; text-align: right; background: #fffefb; }
.inp-sm.auto { background: var(--ochre-soft); border-color: var(--ochre); font-weight: 800; }

/* ---------- comando de voz ---------- */
.voice-panel { background: var(--wood-900) repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 2px, transparent 2px 10px); color: #f4e9d8; border: 0; border-top: 4px solid var(--tag); }
.voice-panel .eyebrow { color: var(--tag); }
.voice-panel h2 { color: #fff; }
.voice-panel .panel-head p { color: #cdb99c; }
.voice-row { display: flex; gap: 10px; align-items: center; padding: 0 18px; }
.voice-row input { flex: 1; min-width: 0; min-height: 50px; padding: 10px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); color: #fff; font-size: 1rem; }
.voice-row input::placeholder { color: #a8957b; }
.mic { width: 58px; height: 58px; border-radius: 50%; border: 3px solid #fff3c9; background: var(--tag); color: var(--wood-950); display: grid; place-items: center; flex: 0 0 auto; }
.mic.listening { background: var(--terra); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(181,84,45,.6); } 100% { box-shadow: 0 0 0 18px rgba(181,84,45,0); } }
.mic-status { padding: 6px 18px 0 86px; color: #a8957b; font-size: .76rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 16px; }
.chip { padding: 6px 10px; border-radius: 4px; border: 1px dashed rgba(242,194,48,.5); background: rgba(242,194,48,.08); color: #f0dfbf; font-size: .78rem; font-weight: 700; }
.chip:hover { background: rgba(242,194,48,.18); }
#voicePreview:not(:empty) { padding: 0 18px 18px; }
.cmd-card { padding: 14px; border-radius: 8px; background: var(--surface); color: var(--ink); display: grid; gap: 12px; border-left: 6px solid var(--tag); }
.cmd-card.bad { background: #fff3ef; color: var(--red); border-left-color: var(--red); }
.cmd-card p { margin: 0; }
.cmd-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cmd-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.cmd-grid > div { padding: 10px; border-radius: 6px; background: #f8f1e4; }
.cmd-grid small { display: block; font-size: .66rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cmd-grid strong { display: block; margin-top: 3px; font-family: var(--slab); }
.cmd-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- fichas de animal y ticket ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px,1fr)); gap: 12px; padding: 0 18px 18px; }
.animal-card { border: 1px solid var(--line-strong); border-top: 4px solid var(--tag); border-radius: 8px; padding: 14px; background: #fffdf6; }
.animal-card h3 { margin: 0; font-size: 1.1rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline { list-style: none; margin: 12px 0 0 6px; padding: 0 0 0 16px; border-left: 2px dashed var(--line-strong); }
.timeline li { position: relative; padding: 0 0 11px 4px; font-size: .82rem; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--pasture); box-shadow: 0 0 0 3px var(--surface); }
.timeline li.out::before { background: var(--terra); }
.timeline li.mv::before { background: var(--blue); }
.timeline li.rz::before { background: var(--ochre); }
.timeline small { display: block; color: var(--muted); font-size: .72rem; }

.ticket-drop { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 0 18px 14px; padding: 14px; border: 2px dashed var(--line-strong); border-radius: 8px; background: #fcf8f0; }
.ticket-drop select, .ticket-drop input[type=file] { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.ticket-lines { margin: 0 18px 14px; padding: 14px 16px; border-radius: 4px; background: #fffbea repeating-linear-gradient(180deg, transparent 0 19px, rgba(0,0,0,.05) 19px 20px); border: 1px solid #eadca8; color: #3a2a0a; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; line-height: 20px; white-space: pre; overflow-x: auto; box-shadow: 3px 3px 0 rgba(90,60,30,.1); }
.reading { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; }
.reading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.listado-text { width: 100%; min-height: 260px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 6px; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; background: #fffbea; }

/* ---------- origen de los datos reales ---------- */
.src-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; padding: 0 18px 14px; }
.src-card { padding: 14px 16px; border: 1px solid var(--line-strong); border-top: 4px solid var(--pasture); border-radius: 8px; background: #fffdf6; min-width: 0; }
.src-file { display: inline-block; padding: 2px 8px; border-radius: 4px; background: #e8f0dc; color: var(--pasture); font-size: .68rem; font-weight: 800; font-family: ui-monospace, Consolas, monospace; }
.src-card h3 { margin: 8px 0 6px; font-family: var(--slab); font-size: 1rem; }
.src-card ul, .src-gaps ul { margin: 0; padding-left: 18px; font-size: .8rem; line-height: 1.55; }
.src-gaps { padding: 12px 16px; border-radius: 8px; background: #fff6df; border-left: 4px solid var(--tag); font-size: .84rem; }
.src-gaps ul { margin-top: 6px; color: var(--muted); }

/* ---------- registro diario: tratamientos, sacos, planta ---------- */
.user-select select { max-width: 190px; }
.timeline li.tx::before { background: var(--red); }
.data-table.compact td, .data-table.compact th { padding: 6px 10px; }
.data-table tfoot td { padding: 9px 12px; border-top: 2px solid var(--line-strong); background: #fbf6ec; }
.warn-box { padding: 10px 12px; border-radius: 6px; background: #fff6df; border-left: 4px solid var(--ochre); color: #8c5f07; font-size: .84rem; font-weight: 650; display: grid; gap: 4px; }
.date-pick { display: flex; align-items: center; gap: 8px; font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.date-pick input { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font: inherit; font-size: .86rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.rac-table select { min-height: 32px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fffefb; max-width: 210px; }
.rac-inp { width: 80px; font-weight: 800; }
.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; padding: 0 18px 18px; }
.formula-card { border: 1px solid var(--line-strong); border-top: 4px solid var(--ochre); border-radius: 8px; background: #fffdf6; display: grid; align-content: start; min-width: 0; }
.formula-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 12px 14px 8px; }
.formula-card header strong { display: block; font-family: var(--slab); font-size: 1.02rem; }
.formula-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.trat-rows { display: grid; gap: 4px; margin-top: 10px; }
.trat-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 140px; gap: 12px; align-items: end; }
.trat-unit { padding-bottom: 10px; }
.perm-table th.c, .perm-table td.c { text-align: center; }
.perm-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--pasture); cursor: pointer; }
.perm-table input[type=checkbox]:disabled { cursor: not-allowed; opacity: .6; }
.perm-table tr.off td { opacity: .55; }
.badge-btn { border: 0; cursor: pointer; font: inherit; }
.area-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding: 0 18px 18px; }
.area-card { padding: 10px 12px; border-radius: 6px; background: #f8f1e4; border-left: 3px solid var(--wood-600); display: grid; gap: 3px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 6px 0 12px; }
.recorrido { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; padding: 0 18px 18px; }
.recorrido button { display: grid; gap: 2px; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fffdf8; cursor: pointer; }
.recorrido button:hover { border-color: var(--wood-600); }
.recorrido b { font-family: var(--slab); color: var(--terra); font-size: 1.1rem; }
.recorrido strong { font-size: .92rem; }
.recorrido span { color: var(--muted); font-size: .75rem; }
.benefit-list { margin: 0; padding: 0 16px 14px 34px; display: grid; gap: 6px; font-size: .86rem; }
.benefit-list li::marker { color: var(--pasture); }
.pager { justify-content: flex-end; }
.check { display: flex; align-items: center; gap: 8px; font-size: .88rem; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 8px; background: var(--wood-950); border-left: 5px solid var(--tag); color: #f4e9d8; box-shadow: var(--shadow); font-size: .86rem; font-weight: 650; max-width: 440px; animation: tin .2s ease-out; }
.toast.err { border-left-color: var(--terra); background: #4a1d12; }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 1450px) {
  .sede-select span { display: none; }
  .user-select select { max-width: 150px; }
}
@media (max-width: 1250px) {
  .group-tab { padding: 9px 11px 20px; font-size: .9rem; }
  .stamp { display: none; }
  .brand span { display: none; }
}
@media (max-width: 1150px) {
  .rh-top { flex-wrap: wrap; row-gap: 0; }
  .group-tabs { order: 3; flex-basis: 100%; margin-left: 0; }
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kv-grid, .cmd-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .src-grid { grid-template-columns: 1fr; }
  .parte { grid-template-columns: 1fr; }
  .parte-actions { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 860px) {
  .rh-top { flex-wrap: wrap; padding: 10px 14px 0; gap: 10px; }
  .group-tabs { order: 3; flex-basis: 100%; margin: 0; overflow-x: auto; }
  .group-tab { top: 0; padding: 9px 12px 12px; }
  .brand span { display: none; }
  .sub-tabs, .page-title-row { padding-left: 14px; padding-right: 14px; }
  main { padding: 14px; }
  .form-grid, .form-grid.two, .subgrid, .cmd-grid, .kv-grid { grid-template-columns: 1fr; }
  .demo-strip .txt { display: none; }
  .demo-strip { justify-content: space-between; }
  .sede-select span { display: none; }
  .parte-date { padding-left: 64px; }
}
