/* Paleta del tambo: cambiar aquí para ajustar a los colores de la marca */
:root {
  --primario: #538442;       /* verde del logo */
  --primario-osc: #1d2e42;   /* azul marino del logo */
  --acento: #86b05e;         /* verde claro */
  --rosado: #f4a7b3;
  --celeste: #b8dfe4;
  --fondo: #faf6e8;          /* crema */
  --tarjeta: #ffffff;
  --texto: #1d2e42;
  --suave: #5f6b73;
  --borde: #e6dfc6;
  --ok: #3f7a2f;
  --alerta: #c77c02;
  --peligro: #b3261e;
  --radio: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; overflow-x: hidden; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto); font-size: 16px; line-height: 1.45; }
a { color: var(--primario); }

/* Barra superior y menú */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--primario-osc); color: #fff; border-bottom: 4px solid var(--acento); height: 60px; }
.topbar a { color: #fff; text-decoration: none; }
.marca { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; flex: 1; min-width: 0; }
.marca span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marca img { height: 36px; width: auto; border-radius: 6px; background: #fff; }
.menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 1.6rem; cursor: pointer; padding: 0 .25rem; }
.salir { font-size: .9rem; opacity: .9; }
.menu { position: fixed; top: 60px; left: 0; bottom: 0; width: 220px; background: var(--primario-osc); padding: 1rem 0; overflow-y: auto; }
.menu a { display: block; padding: .7rem 1.25rem; color: #e8efe6; text-decoration: none; border-left: 4px solid transparent; }
.menu a:hover { background: rgba(255,255,255,.06); }
.menu a.activo { border-left-color: var(--rosado); background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
main { margin-left: 220px; padding: 1.25rem 1.5rem 3rem; max-width: 1200px; }
h1 { margin: .25rem 0 1rem; color: var(--primario-osc); font-size: 1.6rem; }
h2 { color: var(--primario); font-size: 1.2rem; margin: 1.5rem 0 .75rem; }

@media (max-width: 860px) {
  .menu-btn { display: block; }
  .menu { transform: translateX(-100%); transition: transform .2s; z-index: 30; width: 260px; }
  body.menu-abierto .menu { transform: none; box-shadow: 4px 0 16px rgba(0,0,0,.2); }
  main { margin-left: 0; padding: 1rem .8rem 3rem; }
  h1 { font-size: 1.35rem; }
}

/* Tarjetas y avisos */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.tarjeta h2:first-child, .tarjeta h3:first-child { margin-top: 0; }
.aviso { padding: .75rem 1rem; border-radius: var(--radio); margin-bottom: 1rem; border-left: 5px solid; background: #fff; }
.aviso-ok { border-color: var(--ok); }
.aviso-error { border-color: var(--peligro); color: var(--peligro); }
.aviso-alerta { border-color: var(--alerta); background: #fff8e8; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--tarjeta); border: 1px solid var(--borde); border-top: 4px solid var(--primario); border-radius: var(--radio); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.7rem; color: var(--primario-osc); }
.stat span { color: var(--suave); font-size: .9rem; }

/* Botones */
.btn { display: inline-block; font-family: inherit; border: 0; border-radius: 8px; padding: .6rem 1rem; background: var(--primario); color: #fff; font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--primario-osc); }
.btn-sec { background: var(--acento); color: var(--primario-osc); }
.btn-sec:hover { background: #74a04c; }
.btn-borde { background: transparent; color: var(--primario); border: 1.5px solid var(--primario); }
.btn-borde:hover { background: var(--primario); color: #fff; }
.btn-danger { background: var(--peligro); }
.btn-danger:hover { background: #8c1d17; }
.btn-sm { padding: .35rem .65rem; font-size: .82rem; }
.acciones { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
form.inline { display: inline; }

/* Formularios */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: .9rem 1rem; }
.campo label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; color: var(--primario-osc); }
.campo small { color: var(--suave); font-size: .8rem; }
.campo.ancho { grid-column: 1 / -1; }
.form-grid > *, .filtro > *, .campo { min-width: 0; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], select, textarea {
  display: block; width: 100%; max-width: 100%; min-width: 0; padding: .6rem .7rem; border: 1.5px solid var(--borde); border-radius: 8px; font: inherit; font-size: 16px; color: var(--texto); background: #fffdf8;
}
/* iPhone: las fechas no respetan el ancho si no se quita el estilo nativo */
input[type=date] { -webkit-appearance: none; appearance: none; min-height: 2.75rem; text-align: left; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input[type=file] { max-width: 100%; font-size: .85rem; }
select { text-overflow: ellipsis; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primario); box-shadow: 0 0 0 3px rgba(83,132,66,.18); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--primario); }
.opciones { display: flex; gap: .75rem; flex-wrap: wrap; }
.opcion { flex: 1; min-width: 130px; border: 2px solid var(--borde); border-radius: 8px; padding: .7rem; display: flex; gap: .5rem; align-items: center; cursor: pointer; font-weight: 600; }
.opcion input { accent-color: var(--primario); width: 1.2rem; height: 1.2rem; }
.opcion:has(input:checked) { border-color: var(--primario); background: #eef5ee; }
.form-botones { margin-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 560px) {
  .form-botones > .btn, .form-botones > form { flex: 1 1 auto; }
  .form-botones > .btn, .form-botones > form .btn { text-align: center; }
  .form-botones > form .btn { width: 100%; }
  .tarjeta { padding: .9rem; }
  .acciones > .filtro { flex-basis: 100%; }
  .tarjeta .acciones > .btn, .tarjeta .acciones > form.inline { flex: 1 1 100%; text-align: center; }
  .tarjeta .acciones > form.inline .btn { width: 100%; }
}

/* Tablas: en celular se convierten en tarjetas */
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--tarjeta); border-radius: var(--radio); overflow: hidden; border: 1px solid var(--borde); }
th, td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { background: #e3f1f3; color: var(--primario-osc); font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tfoot td { font-weight: 700; background: #faf6ea; }
.chip { font-family: ui-monospace, monospace; font-size: .88rem; word-break: break-all; }
.vacio { color: var(--suave); font-style: italic; }
@media (max-width: 700px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive { border: 0; background: transparent; }
  table.responsive tr { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); margin-bottom: .75rem; padding: .4rem .2rem; }
  table.responsive td { border: 0; padding: .35rem .8rem; display: flow-root; text-align: right; overflow-wrap: anywhere; }
  table.responsive td::before { content: attr(data-label); float: left; margin-right: .75rem; font-weight: 600; color: var(--suave); text-align: left; }
  table.responsive td .tag { margin-top: .2rem; }
  /* Celda de botones (Editar / Eliminar) */
  table.responsive td:not([data-label]) { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: .3rem; padding-top: .6rem; border-top: 1px dashed var(--borde); }
  table.responsive td:not([data-label])::before { content: none; }
  table.responsive td:empty { display: none; }
  table.responsive td.num { text-align: right; }
  table.responsive tfoot tr { background: #faf6ea; }
}

/* Etiquetas de estado */
.tag { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.tag-ok { background: #e2f0e3; color: var(--ok); }
.tag-alerta { background: #fdf0d5; color: #8a5a00; }
.tag-peligro { background: #fbe3e1; color: var(--peligro); }
.tag-neutro { background: #ece8dd; color: var(--suave); }

/* Datos en detalle */
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem 1rem; margin: 0; }
.datos dt { font-size: .8rem; color: var(--suave); text-transform: uppercase; }
.datos dd { margin: 0; font-weight: 600; }

.filtro { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filtro .campo { flex: 1; min-width: 140px; }
/* Botón + buscador + enlace (listas de vacas y terneros) */
.acciones > .filtro { flex: 1 1 260px; flex-wrap: nowrap; }
.acciones > .filtro .campo { min-width: 0; }

/* Popup de alertas */
.modal { position: fixed; inset: 0; background: rgba(20,30,20,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-caja { background: #fff; border-radius: 14px; max-width: 480px; width: 100%; padding: 1.25rem; border-top: 6px solid var(--acento); max-height: 85vh; overflow-y: auto; }
.modal-caja h2 { margin-top: 0; }
.modal-caja ul { padding-left: 1.1rem; }
.modal-caja li { margin-bottom: .5rem; }

/* Selector de datos del PDF */
.pdf-seccion { border: 1px solid var(--borde); border-radius: var(--radio); padding: .8rem 1rem; margin-bottom: .75rem; background: #fff; }
.pdf-cols { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin: .6rem 0 0 1.75rem; }
.pdf-cols .check { font-weight: 400; }

/* Login */
.login { max-width: 360px; margin: 12vh auto; padding: 1rem; }
.login .tarjeta { border-top: 6px solid var(--primario); }
body.pantalla-login { background: linear-gradient(var(--celeste), var(--fondo) 45%); }
.login h1 { text-align: center; }
.login > img { display: block; margin: 0 auto 1rem; max-height: 220px; }

/* Sello de autoría (pie de página): colores del logo de designtech.uy */
.sello { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--borde); text-align: center; font-size: .8rem; color: var(--suave); letter-spacing: .02em; }
.sello a { font-weight: 800; text-decoration: none; letter-spacing: .04em; white-space: nowrap; }
.sello .dt-design { color: #003366; font-style: italic; }
.sello .dt-tech { color: #ff8d4d; font-style: normal; }
.sello a:hover { text-decoration: underline; text-decoration-color: #ff8d4d; }
