:root {
  --teal: #00747a; --teal-dark: #00565b; --turq: #4fcfb9; --turq-soft: #e3f7f2;
  --yellow: #f7e100; --gold: #f2b705; --red: #d7101f; --ink: #12302f; --muted: #5b7472;
  --bg: #f3f8f7; --card: #ffffff; --line: #d9e8e5; --ok: #138a4b; --warn: #e07b00;
  --radius: 18px; --shadow: 0 6px 18px rgba(0, 86, 91, .12);
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); }
[hidden] { display: none !important; }

/* ---------- ingreso ---------- */
.login { min-height: 100dvh; display: grid; place-items: end center; padding: 24px 16px 40px;
  background: url(img/fondo-mascotas.jpg) center / cover no-repeat, var(--turq); }
.login-card { width: min(420px, 100%); background: rgba(255,255,255,.94); border-radius: 26px; padding: 26px 22px 24px;
  box-shadow: 0 18px 40px rgba(0,0,0,.18); text-align: center; backdrop-filter: blur(4px); }
.login-card .masc { width: 150px; height: 150px; object-fit: cover; object-position: center 20%; border-radius: 50%; margin: -95px auto 10px; border: 5px solid #fff; box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.login { place-items: center; }
.login-card { margin-top: 90px; }
.login-card .logos { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 14px; }
.login-card .logos img { height: 46px; width: auto; }
.login-card h1 { margin: 6px 0 4px; font-size: 1.45rem; color: var(--teal-dark); }
.login-card p { margin: 0 0 18px; color: var(--muted); }
#gbtn { display: flex; justify-content: center; min-height: 48px; }
.login-msg { margin-top: 14px; padding: 12px; border-radius: 12px; background: #fde8ea; color: var(--red); font-weight: 700; }
.dev { margin-top: 16px; display: flex; gap: 8px; }

/* ---------- barra superior ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--teal); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.top .back { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 42px; height: 42px; border-radius: 12px; font-size: 1.4rem; cursor: pointer; }
.top .brand { height: 34px; width: auto; border-radius: 6px; cursor: pointer; }
.top .title { flex: 1; font-weight: 800; font-size: 1.1rem; letter-spacing: .3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .who { font-size: .8rem; opacity: .9; text-align: right; line-height: 1.2; }
.top .salir { background: transparent; border: 1px solid rgba(255,255,255,.55); color: #fff; border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: .85rem; }
main { width: min(1100px, 100%); margin: 0 auto; padding: 16px 16px 90px; }

/* ---------- inicio ---------- */
.hola { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--turq) 0%, #7fdcc9 55%, var(--yellow) 160%); box-shadow: var(--shadow); overflow: hidden; }
.hola img { width: 92px; height: 118px; object-fit: cover; border-radius: 14px; flex: none; }
.hola h2 { margin: 0 0 4px; font-size: 1.25rem; color: var(--teal-dark); }
.hola p { margin: 0; color: #0e4a47; font-weight: 600; }
.estado-ruta { margin-top: 14px; padding: 14px 16px; border-radius: 14px; font-weight: 700; display: flex; gap: 10px; align-items: center; }
.estado-ruta.on { background: #e6f6ed; color: var(--ok); border: 2px solid #9fdcb9; }
.estado-ruta.off { background: #fff7d6; color: #7a5b00; border: 2px solid #f3dd7a; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; flex: none; animation: pulso 1.6s infinite; }
@keyframes pulso { 50% { opacity: .35; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }
.tile { background: var(--card); border: 0; border-radius: var(--radius); padding: 12px 10px 14px; cursor: pointer; text-align: center;
  box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; border-bottom: 5px solid var(--yellow); }
.tile:active { transform: scale(.97); }
.tile:hover { box-shadow: 0 10px 24px rgba(0,86,91,.2); }
.tile img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 12px; background: var(--turq-soft); padding: 6px; }
.tile span { display: block; margin-top: 10px; font-weight: 800; font-size: .92rem; color: var(--teal-dark); letter-spacing: .2px; }
.seccion { margin: 26px 4px 0; font-size: .85rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* ---------- formularios ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.form { display: grid; gap: 16px; max-width: 620px; margin: 0 auto; }
.form-head { display: flex; align-items: center; gap: 12px; }
.form-head img { width: 64px; height: 64px; border-radius: 14px; background: var(--turq-soft); object-fit: contain; padding: 4px; }
.form-head h2 { margin: 0; font-size: 1.3rem; color: var(--teal-dark); }
label.f, div.f { display: grid; gap: 8px; font-weight: 900; font-size: 1.12rem; color: #000; }
label.f small { font-weight: 600; color: var(--muted); }
.req::after { content: " *"; color: var(--red); }
input.i, select.i, textarea.i { width: 100%; padding: 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; font-size: 1.05rem; outline: none; }
input.i:focus, select.i:focus, textarea.i:focus { border-color: var(--turq); box-shadow: 0 0 0 4px rgba(79,207,185,.25); }
.fijo { padding: 14px; border-radius: 14px; background: var(--turq-soft); font-weight: 800; color: var(--teal-dark); }
.opciones { display: flex; flex-wrap: wrap; gap: 10px; }
.opciones button { flex: 1 1 120px; padding: 14px 10px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-weight: 800; cursor: pointer; }
.opciones button.sel { border-color: var(--teal); background: var(--teal); color: #fff; }
.foto-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 130px; border: 3px dashed var(--turq); border-radius: 16px;
  background: var(--turq-soft); color: var(--teal-dark); font-weight: 800; cursor: pointer; position: relative; overflow: hidden; text-align: center; padding: 10px; }
.foto-btn img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto-btn { width: 100%; font-size: 1.05rem; }
.foto-btn .rehacer { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff; padding: 6px 10px; border-radius: 10px; font-size: .9rem; }
.camara { position: fixed; inset: 0; z-index: 100; background: #000; display: grid; grid-template-rows: 1fr auto; }
.camara video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam-barra { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); background: #000; }
.cam-disparo { width: 78px; height: 78px; border-radius: 50%; border: 6px solid #fff; background: var(--yellow); cursor: pointer; }
.cam-disparo:active { transform: scale(.94); }
.gps { font-size: .9rem; font-weight: 700; padding: 10px 12px; border-radius: 12px; }
.gps.ok { background: #e6f6ed; color: var(--ok); }
.gps.wait { background: #fff7d6; color: #7a5b00; }
.gps.err { background: #fde8ea; color: var(--red); }
.aviso { padding: 14px; border-radius: 14px; font-weight: 700; line-height: 1.35; }
.aviso.rojo { background: #fde8ea; color: var(--red); border-left: 6px solid var(--red); }
.aviso.amarillo { background: #fff7d6; color: #6b5000; border-left: 6px solid var(--gold); }
.aviso.verde { background: #e6f6ed; color: var(--ok); border-left: 6px solid var(--ok); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 15px 18px; border-radius: 14px; border: 0; cursor: pointer;
  font-weight: 800; font-size: 1.05rem; background: var(--teal); color: #fff; box-shadow: 0 4px 0 var(--teal-dark); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--teal-dark); }
.btn.grande { width: 100%; padding: 18px; font-size: 1.15rem; }
.btn.amarillo { background: var(--yellow); color: var(--teal-dark); box-shadow: 0 4px 0 var(--gold); }
.btn.rojo { background: var(--red); box-shadow: 0 4px 0 #9b0a15; }
.btn.verde { background: var(--ok); box-shadow: 0 4px 0 #0b5c31; }
.btn.claro { background: #fff; color: var(--teal-dark); border: 2px solid var(--line); box-shadow: none; }
.btn.mini { padding: 9px 12px; font-size: .9rem; box-shadow: none; }
.btn:disabled { opacity: .55; cursor: wait; }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; }
.acciones .btn { flex: 1 1 160px; }

/* ---------- listas ---------- */
.barra { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.barra .i { flex: 1 1 200px; padding: 11px 14px; }
.barra input[type=date].i { flex: 0 1 165px; }
.lista { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow);
  cursor: pointer; border-left: 6px solid var(--turq); }
.item .thumb { width: 58px; height: 58px; border-radius: 12px; object-fit: cover; background: var(--turq-soft); flex: none; }
.item .txt { flex: 1; min-width: 0; }
.item b { display: block; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: .88rem; font-weight: 600; }
.item .der { text-align: right; font-size: .82rem; color: var(--muted); font-weight: 700; flex: none; display: grid; gap: 6px; justify-items: end; }
.item.rojo { border-left-color: var(--red); } .item.verde { border-left-color: var(--ok); }
.item.naranja { border-left-color: var(--warn); } .item.amarillo { border-left-color: var(--gold); } .item.gris { border-left-color: #b7c6c3; opacity: .75; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: var(--turq-soft); color: var(--teal-dark); }
.chip.rojo { background: #fde8ea; color: var(--red); } .chip.verde { background: #e6f6ed; color: var(--ok); }
.chip.naranja { background: #ffefd9; color: var(--warn); } .chip.amarillo { background: #fff7d6; color: #7a5b00; }
.vacio { text-align: center; padding: 30px 16px; color: var(--muted); font-weight: 700; }
.vacio img { width: 140px; margin: 0 auto 12px; border-radius: 16px; }
.mas { margin: 16px auto 0; display: flex; }
.fab { position: fixed; right: 18px; bottom: 22px; z-index: 15; width: 66px; height: 66px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--yellow); color: var(--teal-dark); font-size: 2.3rem; font-weight: 900; box-shadow: 0 8px 20px rgba(0,0,0,.25); }

/* ---------- despachos ---------- */
.desp { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); border-left: 6px solid var(--gold); display: grid; gap: 8px; }
.desp.Entregado { border-left-color: var(--ok); } .desp.Rechazado { border-left-color: var(--red); }
.desp h3 { margin: 0; font-size: 1.05rem; }
.desp .row { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-weight: 600; font-size: .92rem; }
.desp .prod { background: var(--turq-soft); border-radius: 10px; padding: 8px 10px; font-weight: 700; }

/* ---------- detalle ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; width: min(640px, calc(100% - 24px)); max-height: calc(100dvh - 40px); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,40,42,.55); }
.dlg-head { position: sticky; top: 0; display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--teal); color: #fff; z-index: 2; }
.dlg-head h3 { margin: 0; flex: 1; font-size: 1.1rem; }
.dlg-head button { background: rgba(255,255,255,.2); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 10px; font-size: 1.2rem; cursor: pointer; }
.dlg-body { padding: 16px; display: grid; gap: 12px; }
.campo { display: grid; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.campo span { font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.campo div { font-weight: 700; word-break: break-word; }
.foto-det { width: 100%; max-height: 360px; object-fit: contain; border-radius: 14px; background: #eef4f3; }

/* ---------- mensajes ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(160%); z-index: 50; max-width: calc(100% - 32px);
  padding: 14px 18px; border-radius: 14px; font-weight: 800; color: #fff; background: var(--teal-dark); box-shadow: 0 10px 26px rgba(0,0,0,.3); transition: transform .25s ease; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }
.cargando { text-align: center; padding: 30px; color: var(--muted); font-weight: 700; }
.exito { text-align: center; display: grid; gap: 14px; justify-items: center; padding: 10px 0; }
.exito img { width: 170px; border-radius: 18px; }
.exito h2 { margin: 0; color: var(--ok); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
@media (max-width: 520px) { .top .who { display: none; } .top { gap: 8px; } }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } .hola img { width: 110px; height: 140px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- pesos y confirmación ---------- */
.pesos { position: relative; }
.pesos span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 900; color: var(--muted); }
.pesos input { padding-left: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.confirmar { padding: 22px 20px; display: grid; gap: 14px; text-align: center; justify-items: center; }
.confirmar img { width: 110px; height: 110px; object-fit: cover; object-position: center 20%; border-radius: 50%; border: 4px solid var(--turq); }
.confirmar h3 { margin: 0; font-size: 1.3rem; color: var(--teal-dark); }
.conf-datos { display: grid; gap: 4px; padding: 12px 14px; background: var(--turq-soft); border-radius: 14px; width: 100%; font-weight: 600; }
.conf-datos b { font-size: 1.05rem; }
.confirmar .acciones { width: 100%; }
.confirmar label.f { width: 100%; text-align: left; }
.lista > * { min-width: 0; }
.item { flex-wrap: wrap; }
.item .abajo { flex-basis: 100%; display: flex; gap: 8px; }
.item .abajo .btn { flex: 1; }

/* ---------- filtro de despachos ---------- */
.filtro-estado { display: flex; gap: 8px; margin-bottom: 8px; }
.filtro-estado button { flex: 1; padding: 13px 8px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-weight: 900; font-size: .95rem; cursor: pointer; }
.filtro-estado button.sel.Pendiente { background: var(--gold); border-color: var(--gold); color: #3d2e00; }
.filtro-estado button.sel.Entregado { background: var(--ok); border-color: var(--ok); color: #fff; }
.filtro-estado button.sel.Rechazado { background: var(--red); border-color: var(--red); color: #fff; }
.nota-filtro { margin: 0 4px 12px; color: var(--muted); font-weight: 700; font-size: .9rem; }
.nota-filtro:empty { display: none; }

/* ---------- autocompletar y reloj ---------- */
.ac { position: relative; }
.ac-lista { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: #fff; border: 2px solid var(--turq); border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18); overflow: hidden; max-height: 300px; overflow-y: auto; }
.ac-lista button { display: block; width: 100%; text-align: left; padding: 13px 14px; border: 0; border-bottom: 1px solid var(--line); background: #fff;
  font-size: 1.05rem; font-weight: 700; cursor: pointer; color: var(--ink); }
.ac-lista button:hover, .ac-lista button:focus { background: var(--turq-soft); }
.ac-vacio { padding: 12px 14px; color: var(--muted); font-weight: 700; }
.reloj-form { display: inline-flex; align-items: center; gap: 6px; justify-self: start; padding: 7px 12px; border-radius: 999px;
  background: var(--turq-soft); color: var(--teal-dark); font-size: .9rem; font-weight: 700; }
.reloj-form b { font-variant-numeric: tabular-nums; }

/* ---------- computador (administradores) ---------- */
.nav-pc { display: none; }
@media (min-width: 1000px) {
  body { background: linear-gradient(180deg, #e7f5f2 0, var(--bg) 320px); }
  .top { padding: 12px 28px; }
  .top .brand { height: 40px; }
  .top .title { font-size: 1.25rem; }
  .nav-pc { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 28px; background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 64px; z-index: 19; }
  .nav-pc button { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 0; border-radius: 12px; background: transparent;
    font-weight: 800; font-size: .8rem; color: var(--teal-dark); cursor: pointer; }
  .nav-pc button img { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; background: var(--turq-soft); }
  .nav-pc button:hover { background: var(--turq-soft); }
  .nav-pc button.act { background: var(--teal); color: #fff; }
  main { width: min(1280px, 100%); padding: 24px 28px 90px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
  .lista { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form { max-width: 760px; padding: 26px 30px; }
  .barra { background: #fff; padding: 12px; border-radius: 16px; box-shadow: var(--shadow); }
  dialog { width: min(760px, calc(100% - 48px)); }
  .fab { right: 36px; bottom: 36px; }
}
@media (min-width: 1500px) { .lista { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
