/* Sistema de Gestión Veterinaria — estilos (sin dependencias externas)
   Rediseño v2: misma identidad verde azulado; más legible (16px), foco visible,
   controles más grandes para uso táctil y menú compacto en celulares. */
:root {
  --bg: #f2f5f4;
  --panel: #ffffff;
  --panel-2: #f7f9f8;          /* segundo plano neutro: encabezados de tabla, unidades */
  --text: #17241f;
  --muted: #56665f;            /* 5.6:1 sobre blanco, 5.2:1 sobre --bg */
  --line: #dce3e0;
  --line-strong: #c3cecb;      /* borde de campos */
  --brand: #0f766e;
  --brand-dark: #0b5952;
  --brand-soft: #e1f2ef;
  --ring: rgba(15, 118, 110, .32);
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #17703a;
  --ok-soft: #e4f3e8;
  --info: #1f4e8c;
  --info-soft: #e8f0fb;
  --side: #12302c;
  --side-2: #183d38;
  --side-text: #cfe0dc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 40, 36, .05);
  --shadow-pop: 0 10px 28px -6px rgba(16, 40, 36, .22), 0 2px 6px rgba(16, 40, 36, .08);
  --control-h: 2.625rem;       /* 42px: altura común de botones y campos */
  --t: 150ms cubic-bezier(.2, .7, .3, 1);
  font-size: 16px;
  accent-color: var(--brand);
  scrollbar-color: #b6c4c0 transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* que una clase con display no muestre elementos ocultos */
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  caret-color: var(--brand);
}
::selection { background: #bfe3dd; color: var(--text); }
a { color: var(--brand); text-decoration: none; text-underline-offset: .18em; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 .9rem; font-weight: 650; }
h3 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 650; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
td, .dinero, .kpi .valor, .cita-hora strong { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--side) 240px, transparent 240px); }
.sidebar { background: var(--side); color: var(--side-text); padding: 1.1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.1rem; padding: .25rem .55rem 1.4rem; letter-spacing: -.005em; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.nav a { display: flex; align-items: center; gap: .7rem; color: var(--side-text); padding: .6rem .75rem; min-height: 2.75rem; border-radius: 10px; margin-bottom: 2px; transition: background var(--t), color var(--t); }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav a.activo { background: #fff; color: var(--side); font-weight: 650; }
.nav a.activo .ico { color: var(--brand); }
.nav a:focus-visible { outline-color: #8fd6cb; }
.nav .sep { font-size: .8rem; font-weight: 600; color: #93b0aa; margin: 1.3rem .75rem .4rem; }
.nav .proximo { opacity: .45; pointer-events: none; }
.nav .proximo small { margin-left: auto; font-size: .68rem; color: var(--side-text); }
.ico { width: 18px; height: 18px; flex: none; }

.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.75rem; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; backdrop-filter: saturate(1.4) blur(6px); }
.buscador { position: relative; flex: 1; max-width: 560px; }
.buscador input { width: 100%; height: var(--control-h); padding: 0 .9rem 0 2.5rem; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font: inherit; color: var(--text); transition: border-color var(--t), box-shadow var(--t), background var(--t); }
.buscador input::placeholder { color: #5b6a64; }
.buscador input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--ring); }
.buscador .ico { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.sugerencias { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); display: none; max-height: 380px; overflow-y: auto; padding: .3rem; }
.sugerencias.abierto { display: block; }
.sugerencias a { display: flex; gap: .7rem; align-items: baseline; padding: .55rem .7rem; color: var(--text); border-radius: 8px; }
.sugerencias a + a { margin-top: 1px; }
.sugerencias a:hover, .sugerencias a.sel { background: var(--brand-soft); text-decoration: none; }
.sugerencias .tipo { font-size: .76rem; font-weight: 600; color: var(--muted); width: 66px; flex: none; }
.sugerencias .vacio { padding: .7rem .8rem; color: var(--muted); }
.usuario-menu { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.usuario-menu .quien { text-align: right; line-height: 1.2; margin-right: .3rem; }
.usuario-menu .quien small { display: block; }

main { padding: 1.75rem; max-width: 1240px; width: 100%; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.encabezado > div > small, .encabezado > div > .muted { display: inline-block; margin-top: .3rem; }
.encabezado .acciones { display: flex; gap: .5rem; flex-wrap: wrap; }
.migas { font-size: .875rem; color: var(--muted); margin-bottom: .35rem; }

/* ---------- Componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.35rem; margin-bottom: 1.35rem; }
.card > h2:first-child, .card > .encabezado:first-child h2 { margin-bottom: .9rem; }
.card.sin-pad { padding: 0; overflow: hidden; }
.card.sin-pad > h2:first-child { padding: 1.1rem 1.35rem 0; }
.grid { display: grid; gap: 1.35rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.kpi { padding: 1.1rem 1.3rem; }
.kpi .valor { font-size: 2rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin-top: .35rem; }
.kpi .etiqueta { color: var(--muted); font-size: .9rem; font-weight: 500; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: var(--control-h); padding: .45rem 1rem; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; color: var(--text); font: inherit; font-weight: 550; line-height: 1.2; cursor: pointer; white-space: nowrap; transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t), transform var(--t); }
.btn:hover { background: var(--panel-2); border-color: #a9b8b4; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primario { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(11, 89, 82, .3); }
.btn.primario:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.peligro { color: var(--danger); border-color: #eebcb6; }
.btn.peligro:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.chico { min-height: 2.125rem; padding: .3rem .7rem; font-size: .875rem; border-radius: 8px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0; min-height: 0; box-shadow: none; }
.btn.link:hover { text-decoration: underline; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); background: var(--panel-2); font-weight: 600; white-space: nowrap; }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: #f6faf9; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactivo td { color: var(--muted); }
td.num, th.num { text-align: right; }
.col-nombre { min-width: 10.5rem; }
@media (max-width: 600px) { .col-nombre { min-width: 8.5rem; } }
.tabla-scroll { overflow-x: auto; }

.badge { display: inline-block; padding: .14rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1.4; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; vertical-align: .08em; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }

.alerta { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1.1rem; border: 1px solid transparent; }
.alerta.success { background: var(--ok-soft); color: var(--ok); border-color: #c6e5cf; }
.alerta.danger { background: var(--danger-soft); color: var(--danger); border-color: #f4c9c3; }
.alerta.warning { background: var(--warn-soft); color: var(--warn); border-color: #f1dfaa; }
.alerta.info { background: var(--info-soft); color: var(--info); border-color: #cddcf2; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 1.35rem; }
.campo label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.campo label .req { color: var(--danger); }
.campo input, .campo select, .campo textarea, .filtros input, .filtros select,
.agenda-nav input[type=date], .agenda-nav select, .periodos input[type=date], .concepto > input {
  width: 100%; min-height: var(--control-h); padding: .5rem .75rem; border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; background: #fff; color: var(--text); transition: border-color var(--t), box-shadow var(--t);
}
.campo input[type=checkbox], .campo input[type=radio], .campo input[type=file] { width: auto; min-height: 0; padding: 0; border: 0; }
.campo input[type=file] { padding: .4rem 0; }
.campo input:hover, .campo select:hover, .campo textarea:hover, .filtros input:hover, .filtros select:hover { border-color: #a9b8b4; }
.campo textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.campo input::placeholder, .campo textarea::placeholder, .filtros input::placeholder, .concepto > input::placeholder, .ms-control input::placeholder { color: #5e6d67; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .filtros input:focus, .filtros select:focus,
.agenda-nav input:focus, .agenda-nav select:focus, .periodos input:focus, .concepto > input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring);
}
.campo.error input, .campo.error select, .campo.error textarea { border-color: var(--danger); background: #fffafa; }
.campo.error input:focus, .campo.error select:focus, .campo.error textarea:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .2); }
.campo .msg { color: var(--danger); font-size: .85rem; font-weight: 500; margin-top: .3rem; }
.campo .ayuda { color: var(--muted); font-size: .84rem; margin-top: .3rem; }
.fila-inline { display: flex; gap: .6rem; }
.fila-inline > * { flex: 1; }
.form-acciones { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.filtros { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.filtros input, .filtros select { width: auto; }
.filtros input[type=search] { min-width: 260px; flex: 1; }
.check { display: inline-flex; gap: .45rem; align-items: center; font-size: .92rem; color: var(--muted); min-height: 2.25rem; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1.1rem; margin: 0; }
legend { font-size: .88rem; font-weight: 600; color: var(--muted); padding: 0 .35rem; }

/* ---------- Fichas ---------- */
.datos { display: grid; grid-template-columns: 150px 1fr; gap: .45rem 1rem; margin: 0; }
.datos dt { color: var(--muted); font-size: .9rem; }
.datos dd { margin: 0; }
.ficha-mascota { display: flex; gap: 1.2rem; align-items: flex-start; }
.foto { width: 140px; height: 140px; border-radius: 16px; object-fit: cover; background: var(--brand-soft); display: grid; place-items: center; color: var(--brand); font-size: 2.6rem; font-weight: 700; flex: none; border: 1px solid var(--line); }
.mini-foto { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--brand-soft); display: inline-grid; place-items: center; color: var(--brand); font-weight: 700; vertical-align: middle; }
.lista-mascotas { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.mascota-item { display: flex; gap: .75rem; align-items: center; padding: .75rem; border: 1px solid var(--line); border-radius: 12px; color: var(--text); transition: border-color var(--t), background var(--t); }
.mascota-item:hover { border-color: var(--brand); text-decoration: none; background: #f6fbfa; }
.mascota-item.inactivo { opacity: .55; }

.linea-tiempo { list-style: none; margin: 0; padding: 0; }
.linea-tiempo li { position: relative; padding: 0 0 1.2rem 1.6rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.linea-tiempo li:last-child { border-left-color: transparent; }
.linea-tiempo li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--brand); }
.linea-tiempo .cab { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.linea-tiempo .det { margin-top: .4rem; display: grid; grid-template-columns: 110px 1fr; gap: .2rem .8rem; font-size: .92rem; }
.linea-tiempo .det dt { color: var(--muted); }
.linea-tiempo .det dd { margin: 0; white-space: pre-line; }
.pre { white-space: pre-line; }

.paginacion { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; font-size: .9rem; color: var(--muted); }
.paginacion .btns { display: flex; gap: .4rem; }
.vacio-estado { text-align: center; padding: 2.75rem 1.25rem; color: var(--muted); }
.vacio-estado .btn { margin-top: .9rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background-color: var(--side);
  background-image: radial-gradient(rgba(255,255,255,.06) 1.5px, transparent 1.5px); background-size: 22px 22px; }
.login-card { width: 100%; max-width: 410px; padding: 2rem 2rem 1.75rem; border: 0; box-shadow: 0 24px 60px -18px rgba(0,0,0,.55); }
.login-card .brand { font-size: 1.3rem; }
.login-card .brand .logo { width: 40px; height: 40px; }
.login-card .btn.primario { width: 100%; min-height: 2.875rem; font-size: 1.02rem; }
.login-card .brand { color: var(--text); justify-content: center; padding-bottom: .4rem; }
.login-card .brand .logo { color: #fff; }


/* ---------- Llenado rápido: chips, unidades, pestañas ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { position: relative; cursor: pointer; user-select: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip > span { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.25rem; padding: .4rem .9rem; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: .92rem; transition: background var(--t), border-color var(--t), color var(--t); }
.chip.grande > span { min-height: var(--control-h); padding: .5rem 1.15rem; font-size: 1rem; font-weight: 500; }
.chip:hover > span { border-color: var(--brand); background: #f6fbfa; }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:checked + span::before { content: "✓"; font-weight: 700; }
.chip input:checked:hover + span { background: var(--brand-dark); }
.chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.chip.nuevo span { border-style: dashed; }
.chip-ref { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .8rem; margin: 0 .25rem .25rem 0; }
.campo .chips + input, .campo .fila-agregar { margin-top: .5rem; }
.fila-agregar { display: flex; gap: .5rem; }
.fila-agregar input { flex: 1; }
.con-unidad { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; overflow: hidden; transition: border-color var(--t), box-shadow var(--t); }
.con-unidad input { border: 0 !important; outline: none !important; box-shadow: none !important; min-width: 0; border-radius: 0 !important; }
.con-unidad span { padding: 0 .75rem; color: var(--muted); font-size: .9rem; background: var(--panel-2); align-self: stretch; display: flex; align-items: center; border-left: 1px solid var(--line); }
.con-unidad:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.campo select:disabled { background: var(--bg); color: var(--muted); }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: 0 0 1rem; }
.tabs button { border: 0; background: none; padding: .65rem 1rem; min-height: 2.75rem; font: inherit; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color var(--t), border-color var(--t); }
.tabs button:hover { color: var(--text); }
.tabs button.activo { color: var(--brand-dark); border-bottom-color: var(--brand); }
.panel-tab { display: none; }
.panel-tab.activo { display: block; }

/* Casos */
.casos-elegir { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.caso-card { display: block; border: 1px solid var(--line-strong); border-radius: 12px; padding: 1rem 1.1rem; transition: border-color var(--t), background var(--t); background: #fff; color: var(--text); cursor: pointer; position: relative; }
.caso-card:hover { border-color: var(--brand); text-decoration: none; background: #fbfefd; }
.caso-card input { position: absolute; opacity: 0; }
.caso-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); background: #f6fbfa; }
.caso-card .tema { font-weight: 700; font-size: 1.02rem; }
.caso-card.nuevo-caso { border-style: dashed; }
.estado-activo { background: var(--ok-soft); color: var(--ok); }
.estado-seguimiento { background: var(--warn-soft); color: var(--warn); }
.estado-cerrado { background: var(--bg); color: var(--muted); }

.consulta-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.2rem; align-items: start; }
.antecedentes { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.antecedentes h2 { font-size: 1rem; }
.antecedentes .visita { border-top: 1px solid var(--line); padding: .7rem 0; font-size: .9rem; }
.antecedentes .visita:first-of-type { border-top: 0; }
.antecedentes dl { display: grid; grid-template-columns: 92px 1fr; gap: .2rem .6rem; margin: .4rem 0 0; }
.antecedentes dt { color: var(--muted); font-size: .8rem; }
.antecedentes dd { margin: 0; white-space: pre-line; }
.btn-usar { font-size: .78rem; padding: .1rem .5rem; margin-left: .3rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--brand); cursor: pointer; }
.btn-usar:hover { background: var(--brand-soft); }
.seccion-form { grid-column: 1 / -1; font-size: 1.02rem; color: var(--text); font-weight: 650; border-bottom: 1px solid var(--line); padding-bottom: .45rem; margin-top: 1rem; }
.seccion-form:first-child { margin-top: 0; }
.grupo-fecha { font-weight: 650; color: var(--muted); font-size: .88rem; margin: 1.1rem 0 .45rem; }
.grupo-fecha:first-child { margin-top: 0; }
.pesos { display: flex; gap: .4rem; flex-wrap: wrap; font-size: .85rem; }
.pesos span { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .2rem .55rem; }
@media (max-width: 1100px) { .consulta-layout { grid-template-columns: 1fr; } .antecedentes { position: static; max-height: none; } }

@media (max-width: 900px) {
  /* Menú lateral → barra superior compacta con accesos deslizables */
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; overflow: visible; padding: .55rem .75rem .6rem;
    display: flex; align-items: center; gap: .6rem; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
  .brand { padding: 0; flex: none; font-size: 0; gap: 0; }   /* en celular solo el logotipo */
  .brand .logo { width: 32px; height: 32px; }
  .nav { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0;
    mask-image: linear-gradient(to right, #000 88%, transparent); -webkit-mask-image: linear-gradient(to right, #000 88%, transparent);
    padding-right: 1.5rem; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: none; margin: 0; min-height: 2.5rem; padding: .45rem .8rem; white-space: nowrap; font-size: .93rem; border-radius: 999px; }
  .nav .sep { display: none; }
  .nav .contador { margin-left: .2rem; }
  .topbar { position: static; flex-wrap: wrap; gap: .6rem; padding: .7rem 1rem; backdrop-filter: none; background: #fff; }
  .buscador { order: 2; flex: 1 1 100%; max-width: none; }
  .usuario-menu { order: 1; width: 100%; }
  .usuario-menu .quien { display: block; text-align: left; margin-right: auto; font-size: .92rem; }
  .g2, .g3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .kpi { padding: .9rem 1rem; }
  .kpi .valor { font-size: 1.55rem; }
  .span2 { grid-column: auto; }
  main { padding: 1.1rem 1rem 2rem; }
  h1 { font-size: 1.5rem; }
  .card { padding: 1.1rem; margin-bottom: 1rem; }
  .grid { gap: 1rem; }
  .ficha-mascota { flex-direction: column; }
  th, td { padding: .7rem .8rem; }
  .datos { grid-template-columns: 112px minmax(0, 1fr); }
  .btn.chico { min-height: 2.5rem; padding: .35rem .8rem; }   /* objetivos táctiles de 40px o más */
  .encabezado { align-items: flex-start; }
  .form-acciones { position: sticky; bottom: 0; background: #fff; margin-left: -1.1rem; margin-right: -1.1rem; margin-bottom: -1.1rem;
    padding: .8rem 1.1rem; border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 14px -10px rgba(16,40,36,.35); z-index: 5; }
  .form-acciones .btn { flex: 1; }
  html { scroll-padding-bottom: 5.5rem; scroll-padding-top: 4rem; }   /* que la barra fija no tape el campo enfocado */
}
@media print {
  .sidebar, .topbar, .acciones, .btn, main > .alerta { display: none !important; }
  .app { display: block; background: none; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}

/* ---------- Selector de búsqueda múltiple (Signos) ---------- */
.ms { position: relative; }
.ms-control { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; transition: border-color var(--t), box-shadow var(--t); }
.ms-control:focus-within, .ms.abierto .ms-control { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.campo .ms-control input, .campo .ms-control select { box-shadow: none !important; min-height: calc(var(--control-h) - 2px); }
.ms-control > .ico { align-self: center; margin-left: .7rem; color: var(--muted); }
.campo .ms-control input { border: 0; outline: none; flex: 1; min-width: 0; padding: .6rem .6rem; background: transparent; }
.campo .ms-control select { width: auto; max-width: 45%; border: 0; border-left: 1px solid var(--line); border-radius: 0 10px 10px 0; background: var(--panel-2); color: var(--text); font-size: .88rem; padding: 0 .6rem; }
.ms-lista { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: .3rem; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); max-height: 300px; overflow-y: auto; overscroll-behavior: contain; }
.ms-opcion { display: flex; align-items: center; gap: .6rem; padding: .55rem .65rem; min-height: 2.5rem; border-radius: 8px; cursor: pointer; }
.ms-opcion.activo { background: var(--brand-soft); }
.ms-opcion:hover { background: #f1f7f6; }
.ms-opcion.activo:hover { background: var(--brand-soft); }
.ms-check { width: 18px; height: 18px; flex: none; border: 1.5px solid #9fb2ad; border-radius: 4px; display: grid; place-items: center; font-size: .75rem; color: #fff; }
.ms-opcion.marcado .ms-check { background: var(--brand); border-color: var(--brand); }
.ms-opcion.marcado .ms-check::after { content: "✓"; font-weight: 700; }
.ms-opcion.marcado .ms-nombre { font-weight: 600; }
.ms-nombre { flex: 1; }
.ms-cat { color: var(--muted); font-size: .75rem; text-align: right; }
.ms-sin-resultados { padding: .7rem .6rem; color: var(--muted); display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.ms-seleccion { margin-top: .7rem; }
.ms-titulo { font-size: .86rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; }
.ms-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.ms-chip { display: inline-flex; align-items: center; gap: .2rem; max-width: 100%; min-height: 2.125rem; padding: .2rem .3rem .2rem .75rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: .9rem; font-weight: 500; border: 1px solid #b9e0db; }
.ms-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-chip.nuevo { border-style: dashed; }
.ms-quitar { border: 0; background: transparent; color: var(--brand-dark); width: 28px; height: 28px; border-radius: 50%; font-size: 1.1rem; line-height: 1; cursor: pointer; flex: none; }
.ms-quitar:hover { background: rgba(11, 89, 82, .15); }
.ms-quitar:focus-visible { background: rgba(11, 89, 82, .15); outline: 2px solid var(--brand); outline-offset: 0; }
.ms-vacio { margin: 0; color: var(--muted); font-size: .88rem; }
@media (max-width: 600px) {
  .ms-control { flex-wrap: wrap; }
  .campo .ms-control select { max-width: none; width: 100%; border-left: 0; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; padding: .5rem .6rem; }
  .ms-cat { display: none; }
  .ms-lista { max-height: 50vh; }
}

/* ---------- Fase 2: vacunas y citas ---------- */
.tab-link { display: inline-flex; align-items: center; min-height: 2.75rem; padding: .6rem 1rem; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; transition: color var(--t), border-color var(--t); }
.tab-link:hover { text-decoration: none; color: var(--text); }
.tab-link.activo { color: var(--brand-dark); border-bottom-color: var(--brand); }
.vac-vencida { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.vac-semana { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.vac-mes { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }
.vac-al_dia { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.texto-peligro { color: var(--danger); font-weight: 600; }
tr.anulada td { color: var(--muted); text-decoration: line-through; }
tr.anulada td:last-child { text-decoration: none; }

.cita-programada { background: var(--info-soft); color: #1f4e8c; border-color: transparent; }
.cita-confirmada { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.cita-atendida { background: var(--bg); color: var(--muted); }
.cita-cancelada { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.cita-no_asistio { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.agenda-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.agenda-nav input[type=date], .agenda-nav select, .periodos input[type=date] { width: auto; }
.agenda-dia { list-style: none; margin: 0; padding: 0; }
.cita-item { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 1rem; align-items: start; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.cita-item:last-child { border-bottom: 0; }
.cita-item.cancelada, .cita-item.no_asistio { opacity: .6; }
.cita-item.atendida .cita-hora strong { color: var(--muted); }
.cita-hora strong { font-size: 1.25rem; display: block; line-height: 1.2; letter-spacing: -.01em; }
.cita-hora small { color: var(--muted); }
.cita-acciones { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.cita-acciones form { display: inline; }
.libre-hueco { padding: .5rem 1.25rem; border-bottom: 1px dashed var(--line); color: var(--muted); font-size: .88rem; display: flex; justify-content: space-between; align-items: center; }
.semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.semana-dia { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-height: 160px; display: flex; flex-direction: column; }
.semana-dia.hoy { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.semana-dia header { padding: .5rem .6rem; border-bottom: 1px solid var(--line); font-size: .85rem; display: flex; justify-content: space-between; }
.semana-dia header a { color: var(--text); font-weight: 600; }
.semana-dia .mini { display: block; padding: .4rem .55rem; margin: .3rem .35rem 0; border-radius: 8px; font-size: .82rem; color: var(--text); background: var(--brand-soft); }
.semana-dia .mini:hover { text-decoration: none; background: var(--brand-soft); }
.semana-dia .mini:hover { background: #cbe9e4; }
.semana-dia .mini.cancelada { background: var(--danger-soft); opacity: .7; text-decoration: line-through; }
.semana-dia .mini.atendida { background: var(--panel-2); color: var(--muted); }
.semana-dia .agregar { margin: auto .35rem .4rem; font-size: .8rem; text-align: center; }
.horarios { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .5rem; }
.horarios .chip > span { width: 100%; justify-content: center; }
.horarios .chip.ocupado > span { background: var(--bg); color: var(--muted); text-decoration: line-through; }
.horarios .chip .n { font-size: .7rem; background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 0 .35rem; margin-left: .2rem; }
.horarios .chip input:checked + span .n { background: rgba(255,255,255,.25); color: #fff; }
.buscador-mascota { position: relative; }
.buscador-mascota .sugerencias { top: calc(100% + 2px); }
.mascota-elegida { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border: 1px solid var(--brand); background: #f3faf8; border-radius: 12px; }
.mascota-elegida .datos-m { flex: 1; }
@media (max-width: 900px) {
  .semana { grid-template-columns: 1fr; }
  .semana-dia { min-height: 0; }
  .cita-item { grid-template-columns: 70px minmax(0, 1fr); }
  .cita-acciones { grid-column: 1 / -1; justify-content: flex-start; }
}
.menu-cancelar { position: relative; display: inline-block; }
.menu-cancelar > summary { list-style: none; }
.menu-cancelar > summary::-webkit-details-marker { display: none; }
.menu-cancelar-caja { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); padding: .6rem; display: flex !important; flex-direction: column; gap: .35rem; min-width: 200px; }
.menu-cancelar-caja .btn { justify-content: flex-start; }
.enlace-kpi { color: var(--text); transition: border-color var(--t), background var(--t); }
.enlace-kpi:hover { text-decoration: none; border-color: var(--brand); background: #fbfdfd; }
.cita-item.compacta { grid-template-columns: 64px minmax(0, 1fr) auto; padding: .75rem 1.25rem; }
@media (max-width: 900px) { .cita-item.compacta { grid-template-columns: 64px minmax(0, 1fr); } }

/* ---------- Fase 3: pagos, reportes, recordatorios ---------- */
.conceptos { display: grid; gap: .45rem; }
.concepto { display: grid; grid-template-columns: minmax(0, 1fr) 170px 32px; gap: .5rem; align-items: center; }
.concepto .con-unidad span, .fila-agregar .con-unidad span { border-left: 0; border-right: 1px solid var(--line); order: -1; }
.concepto .ms-quitar { color: var(--muted); width: 32px; height: 32px; }
.concepto .ms-quitar:hover { color: var(--danger); background: var(--danger-soft); }
.total-cobro { margin-top: 1rem; padding: .8rem 1rem; font-size: 1.1rem; text-align: right; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.total-cobro strong { font-size: 1.65rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
tr.cancelado td { color: var(--muted); text-decoration: line-through; }
tr.cancelado td:last-child { text-decoration: none; }
.dinero { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.recibo { max-width: 560px; margin: 0 auto; }
.recibo .cab { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--text); padding-bottom: .6rem; margin-bottom: .8rem; }
.recibo table td, .recibo table th { padding: .45rem .3rem; }
.recibo .total td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--text); border-bottom: 0; }
.sello-cancelado { border: 2px solid var(--danger); color: var(--danger); font-weight: 700; padding: .3rem .8rem; border-radius: 6px; display: inline-block; transform: rotate(-4deg); }
.periodos { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }

.barras { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.barras li { display: grid; grid-template-columns: minmax(110px, 34%) minmax(0, 1fr) auto; gap: .6rem; align-items: center; font-size: .9rem; }
.barras .pista { height: 12px; background: var(--panel-2); border-radius: 0 4px 4px 0; }
.barras .barra { height: 12px; border-radius: 0 4px 4px 0; background: var(--brand); min-width: 2px; }
.barras .valor { font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.columnas { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: .5rem; border-bottom: 1px solid var(--line); }
.columnas .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; cursor: default; }
.columnas .col .b { background: var(--brand); border-radius: 4px 4px 0 0; min-height: 0; }
.columnas .col:hover .b { background: var(--brand-dark); }
.columnas .col .tip { display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; font-size: .75rem; padding: .25rem .5rem; border-radius: 6px; white-space: nowrap; z-index: 5; }
.columnas .col:hover .tip { display: block; }
.columnas-ejes { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: .25rem; }
.recordatorio { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.recordatorio:last-child { border-bottom: 0; }
.recordatorio.enviado { background: var(--panel-2); }
.recordatorio .estado-envio { font-size: .84rem; font-weight: 600; color: var(--ok); }
.contador { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: .75rem; font-weight: 700; min-width: 1.4rem; text-align: center; padding: .08rem .45rem; font-variant-numeric: tabular-nums; }
@media print {
  .recibo { max-width: none; }
  .no-imprimir { display: none !important; }
}
@media (max-width: 600px) {
  .concepto { grid-template-columns: minmax(0, 1fr) 120px 28px; }
  .recordatorio { grid-template-columns: 1fr; }
}
.app > div { min-width: 0; }     /* evita que contenido ancho estire la página en celulares */
@media (max-width: 600px) { .periodos input[type=date] { width: 9.5rem; } }
