/* ARVIA · capa de diseño y movimiento (se carga en todos los paneles, después de ui.css y antes de dark.css).
   Animaciones suaves y con propósito: entrada de la página, menús que se despliegan, tarjetas que responden
   al cursor y números que cuentan. Todo se desactiva con «reducir movimiento». */

/* ---------- Marca ARVIA ----------
   Azul ARVIA #023163 · Turquesa ARVIA #13A8AA · Petróleo #155E75 (interfaz) · Pizarra #526D80 (emblema)
   Bruma #E8F8F5 · Tinta #0F172A · Nieve #F8FAFC. Logotipo en Poppins Medium; interfaz en Inter. */
@font-face { font-family: "ARVIA Brand"; src: url("/fonts/Poppins-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
.sidebar-brand, .navbar-brand span, .footer-brand span, .mobile-topbar strong {
    font-family: "ARVIA Brand", Poppins, Inter, sans-serif !important; font-weight: 500 !important; letter-spacing: .12em; color: #023163 !important;
}
.sidebar-logo, .navbar-logo, .footer-logo { object-fit: contain }

:root {
    --brand-navy: #023163; --brand-teal: #13A8AA; --brand-petrol: #155E75; --brand-slate: #526D80; --brand-mist: #E8F8F5;
    --a-ease: cubic-bezier(.2, .8, .2, 1);
    --a-ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --a-teal: #0E7490;
    --a-teal-dark: #155E75;
    --a-teal-soft: #E0F2FE;
    --a-mint: #D1FAE5;
    --a-ink: #0F172A;
    --a-ink-2: #334155;
    --a-muted: #64748B;
    --a-line: #E2E8F0;
    --a-card: #FFFFFF;
    --a-bg: #F8FAFC;
    --a-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
    --a-shadow-lift: 0 2px 4px rgba(15, 23, 42, .05), 0 16px 36px rgba(15, 23, 42, .10);
}

@keyframes arvia-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes arvia-rise { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes arvia-slide { from { opacity: 0; transform: translateY(-6px) } to { opacity: 1; transform: none } }
@keyframes arvia-pop { 0% { transform: scale(.6); opacity: 0 } 70% { transform: scale(1.08) } 100% { transform: scale(1); opacity: 1 } }
@keyframes arvia-pulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55) } 70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0) } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0) } }
@keyframes arvia-grow-y { from { transform: scaleY(0) } to { transform: scaleY(1) } }
@keyframes arvia-grow-x { from { transform: scaleX(0) } to { transform: scaleX(1) } }
@keyframes arvia-shimmer { from { background-position: -200% 0 } to { background-position: 200% 0 } }
@keyframes arvia-wiggle { 0%, 100% { transform: rotate(0) } 25% { transform: rotate(-8deg) } 75% { transform: rotate(8deg) } }

/* ---------- Entrada de la página ---------- */
.page-content > .dashboard-page > *,
.page-content > .dashboard-page > .kpi-grid > *,
.page-content > .dashboard-page > .stats-grid > * {
    animation: arvia-rise .45s var(--a-ease) both;
}
.page-content > .dashboard-page > *:nth-child(2) { animation-delay: .04s }
.page-content > .dashboard-page > *:nth-child(3) { animation-delay: .08s }
.page-content > .dashboard-page > *:nth-child(4) { animation-delay: .12s }
.page-content > .dashboard-page > *:nth-child(5) { animation-delay: .16s }
.page-content > .dashboard-page > *:nth-child(n+6) { animation-delay: .2s }
.kpi-grid > *:nth-child(2), .stats-grid > *:nth-child(2) { animation-delay: .05s !important }
.kpi-grid > *:nth-child(3), .stats-grid > *:nth-child(3) { animation-delay: .1s !important }
.kpi-grid > *:nth-child(4), .stats-grid > *:nth-child(4) { animation-delay: .15s !important }
.kpi-grid > *:nth-child(5) { animation-delay: .2s !important }
.kpi-grid > *:nth-child(6) { animation-delay: .25s !important }

/* Aparecer con un pequeño desfase (solo CSS: no depende de que cargue el JavaScript, así no parpadea). */
.reveal { animation: arvia-rise .45s var(--a-ease) both }
.crm-grid > .reveal:nth-child(2) { animation-delay: .05s }
.crm-grid > .reveal:nth-child(3) { animation-delay: .1s }
.crm-grid > .reveal:nth-child(4) { animation-delay: .15s }
.crm-grid > .reveal:nth-child(n+5) { animation-delay: .2s }

/* En el celular, una sola barra superior: la de la página se oculta (ya está la del menú). */
@media (max-width: 900px) {
    .topbar { display: none !important }
}

/* Tarjeta de la persona en el menú y enlace a «Mi perfil» */
.sidebar-person { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; flex: 1; min-width: 0; border-radius: 12px; padding: 4px; margin: -4px; transition: background .2s ease }
.sidebar-person:hover { background: #F1F5F9 }
.sidebar-person .sidebar-user-info { min-width: 0 }
.sidebar-person .sidebar-user-info strong, .sidebar-person .user-role { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.profile-link { display: flex; justify-content: center; width: 100%; margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: #E0F2FE; color: #155E75; font-size: 13px; font-weight: 700; text-decoration: none; transition: background .2s ease, transform .15s var(--a-ease) }
.profile-link:hover { background: #BAE6FD; transform: translateY(-1px) }
html[data-theme="dark"] .sidebar-person:hover { background: #17233A }
html[data-theme="dark"] .profile-link { background: #0B3A47; color: #7DD3E4 }

/* ---------- Menú lateral ---------- */
.sidebar { transition: transform .3s var(--a-ease), box-shadow .3s ease }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px }
.nav-item {
    position: relative;
    gap: 10px !important;
    padding: 10px 14px !important;
    margin-bottom: 2px !important;
    font-size: 14px;
    font-weight: 500;
    transition: background .2s ease, color .2s ease, transform .2s var(--a-ease) !important;
}
.nav-item:hover { transform: translateX(3px) }
.nav-item.active { box-shadow: 0 6px 16px rgba(21, 94, 117, .25) }
.nav-item.active::before {
    content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--a-teal);
    animation: arvia-grow-y .3s var(--a-ease) both;
}
.nav-ico { display: inline-flex; width: 20px; justify-content: center; font-size: 18px; flex-shrink: 0 }
.nav-item:hover .nav-ico { animation: arvia-wiggle .4s ease }
.nav-label { flex: 1; min-width: 0 }

.nav-group { padding: 0 16px; margin: 2px 0 }
.nav-group-title {
    list-style: none; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 12px;
    color: var(--a-muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    transition: background .2s ease, color .2s ease;
}
.nav-group-title::-webkit-details-marker { display: none }
.nav-group-title:hover { background: #F1F5F9; color: var(--a-ink-2) }
.nav-group-title .nav-ico { font-size: 16px }
.nav-chev { width: 16px; height: 16px; margin-left: auto; transition: transform .25s var(--a-ease) }
.nav-group[open] > .nav-group-title .nav-chev { transform: rotate(180deg) }
.nav-group[open] > .nav-group-title { color: var(--a-teal-dark) }
.nav-group-items { padding: 2px 0 6px 10px; margin-left: 9px; border-left: 2px solid var(--a-line) }
.nav-group[open] > .nav-group-items { animation: arvia-slide .25s var(--a-ease) both }
.nav-group-items .nav-item.active::before { left: -12px }

/* ---------- Botones y tarjetas ---------- */
.btn-add-pet, .plan-btn, .qa, .ui-btn {
    transition: transform .15s var(--a-ease), box-shadow .2s ease, background .2s ease, filter .2s ease !important;
}
.btn-add-pet:hover, .qa:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(14, 116, 144, .22) }
.btn-add-pet:active, .plan-btn:active, .qa:active, .ui-btn:active { transform: scale(.97) }

.stat-card, .pet-card, .appointment-card, .crm-card, .kpi {
    transition: transform .25s var(--a-ease), box-shadow .25s ease, border-color .25s ease;
}
a.stat-card:hover, .pet-card:hover, a.appointment-card:hover, a.kpi:hover {
    transform: translateY(-3px); box-shadow: var(--a-shadow-lift); border-color: #A5F3FC;
}
.stat-card .stat-icon { transition: transform .3s var(--a-ease-spring) }
.stat-card:hover .stat-icon { transform: scale(1.1) rotate(-6deg) }
.form-card { box-shadow: var(--a-shadow) }
.empty-state { animation: arvia-fade .5s ease both }

/* Pastillas de estado (siempre con texto, nunca solo color) */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border-radius: 99px; padding: 2px 10px; white-space: nowrap; background: #F1F5F9; color: var(--a-ink-2) }
.pill-ok { background: #D1FAE5; color: #047857 }
.pill-info { background: #E0F2FE; color: #0369A1 }
.pill-warn { background: #FEF3C7; color: #B45309 }
.pill-muted { background: #F1F5F9; color: #475569 }

/* ---------- Panel tipo CRM ---------- */
.crm-filter select { border: 1px solid var(--a-line); border-radius: 10px; padding: 9px 12px; background: var(--a-card); color: var(--a-ink); font-size: 14px; min-width: 210px }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px }
.kpi {
    position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 4px;
    background: var(--a-card); border: 1px solid var(--a-line); border-radius: 16px; padding: 16px 18px;
    text-decoration: none; color: inherit; box-shadow: var(--a-shadow);
}
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, rgba(14, 116, 144, .10), transparent 70%); transition: transform .4s var(--a-ease) }
.kpi:hover::after { transform: scale(1.4) }
.kpi-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--a-muted) }
.kpi-value { font-size: 2rem; line-height: 1.1; color: var(--a-ink); font-variant-numeric: tabular-nums; display: inline-block; animation: arvia-pop .5s var(--a-ease-spring) .15s both; transform-origin: left center }
.kpi-sub { font-size: 12px; color: var(--a-muted) }
.kpi-accent { background: linear-gradient(135deg, #155E75, #0E7490 60%, #0891B2); border-color: transparent; color: #fff }
.kpi-accent .kpi-label, .kpi-accent .kpi-sub { color: rgba(255, 255, 255, .82) }
.kpi-accent .kpi-value { color: #fff }
.kpi-accent::after { background: radial-gradient(circle, rgba(255, 255, 255, .25), transparent 70%) }
.trend { font-weight: 700 }
.trend.up { color: #047857 }
.trend.down { color: #B91C1C }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px }
.quick-actions .qa { background: var(--a-card); border: 1px solid var(--a-line); color: var(--a-teal-dark); border-radius: 99px; padding: 8px 14px; font-size: 13px; font-weight: 600; text-decoration: none }
.quick-actions .qa:first-child { background: var(--a-teal); color: #fff; border-color: transparent }

.crm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start }
.crm-card { background: var(--a-card); border: 1px solid var(--a-line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--a-shadow); min-width: 0 }
.crm-wide { grid-column: span 2 }
.crm-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px }
.crm-card-head h3 { margin: 0; font-size: 1rem; color: var(--a-ink) }
.crm-card-head a { font-size: 13px; font-weight: 600; color: var(--a-teal) }
.crm-muted { color: var(--a-muted); font-size: 13px }

/* Barras: un solo color (magnitud), extremos redondeados, hoy resaltado, tooltip al pasar o enfocar. */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 22px }
.bar-slot { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; outline: none }
.bar { width: 100%; height: var(--h); background: #67C5D9; border-radius: 4px 4px 0 0; transform-origin: bottom; animation: arvia-grow-y .6s var(--a-ease) both; transition: background .2s ease }
.bar.today { background: var(--a-teal-dark) }
.bar.zero { background: var(--a-line) }
.bar-slot:hover .bar, .bar-slot:focus .bar { background: var(--a-teal) }
.bar-slot::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% - 18px); left: 50%; transform: translate(-50%, 4px);
    background: var(--a-ink); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 8px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; z-index: 2;
}
.bar-slot:hover::after, .bar-slot:focus::after { opacity: 1; transform: translate(-50%, 0) }
.bars .bar-slot:nth-child(-n+4)::after { left: 0; transform: translate(0, 4px) }
.bars .bar-slot:nth-last-child(-n+4)::after { left: auto; right: 0; transform: translate(0, 4px) }
.bars .bar-slot:nth-child(-n+4):hover::after, .bars .bar-slot:nth-last-child(-n+4):hover::after { transform: none }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--a-muted); margin-top: 6px }
.crm-table-toggle { margin-top: 10px; font-size: 13px }
.crm-table-toggle summary { cursor: pointer; color: var(--a-teal); font-weight: 600 }

.crm-table-wrap { overflow-x: auto }
.crm-table { width: 100%; border-collapse: collapse; font-size: 14px }
.crm-table th { text-align: left; font-size: 12px; color: var(--a-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--a-line); white-space: nowrap }
.crm-table td { padding: 10px; border-bottom: 1px solid #F1F5F9 }
.crm-table tbody tr { transition: background .15s ease }
.crm-table tbody tr:hover, .crm-table tr.sel { background: #F0FDFA }
.crm-table a { color: inherit; text-decoration: none }

.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px }
.team-list li { display: flex; align-items: center; gap: 10px; animation: arvia-rise .4s var(--a-ease) both }
.team-main { flex: 1; min-width: 0; display: flex; flex-direction: column }
.team-main b { font-size: 14px; color: var(--a-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.team-main small { font-size: 12px; color: var(--a-muted) }
.avatar { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--a-teal-soft); color: var(--a-teal-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0 }
.avatar i { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--a-card); background: #CBD5E1 }
.avatar.online i { background: #10B981 }
.avatar.duty i { background: #10B981; animation: arvia-pulse 2s infinite }

.rank { margin-bottom: 12px }
.rank-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--a-ink-2); margin-bottom: 4px }
.meter { height: 8px; background: #F1F5F9; border-radius: 99px; overflow: hidden }
.meter > div { height: 100%; width: var(--w); background: var(--a-teal); border-radius: 99px; transform-origin: left; animation: arvia-grow-x .7s var(--a-ease) both }
.meter.warn > div { background: #F59E0B }
.meter.full > div { background: #DC2626 }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--a-line); display: grid; gap: 12px }
.timeline li { position: relative; font-size: 14px }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--a-card); border: 2px solid #94A3B8 }
.timeline li.st-waiting::before { border-color: #F59E0B }
.timeline li.st-in_consultation::before { border-color: var(--a-teal); background: var(--a-teal) }
.timeline li.st-done::before { border-color: #10B981; background: #10B981 }
.timeline small { display: block; color: var(--a-muted); font-size: 12px; margin-top: 2px }

/* ---------- Recepción: ¿tiene tutor? ---------- */
.custody-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-bottom: 14px }
.custody-choice label { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--a-line); border-radius: 12px; padding: 10px 12px; cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s var(--a-ease) }
.custody-choice label:hover { transform: translateY(-1px) }
.custody-choice input { width: auto !important; margin-top: 3px; accent-color: var(--a-teal) }
.custody-choice span { display: flex; flex-direction: column }
.custody-choice small { color: var(--a-muted); font-size: 12px }
.custody-choice label:has(input:checked) { border-color: var(--a-teal); background: #F0FDFA }
[data-tutor][hidden], [data-origin][hidden], [data-temp][hidden] { display: none !important }
.custody-list { display: grid; gap: 10px }
.custody-item > summary { list-style: none; cursor: pointer; display: flex; gap: 12px; align-items: center }
.custody-item > summary::-webkit-details-marker { display: none }
.custody-item[open] > summary { margin-bottom: 12px }
.custody-item[open] .custody-body { animation: arvia-slide .25s var(--a-ease) both }
.custody-avatar { width: 44px; height: 44px; border-radius: 12px; background: var(--a-teal-soft); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; overflow: hidden; flex-shrink: 0 }
.custody-avatar img { width: 100%; height: 100%; object-fit: cover }
.custody-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px }
.custody-main small { color: var(--a-muted); font-size: 12px }
.custody-when { font-size: 12px; color: var(--a-muted); text-align: right }

/* ---------- Notificaciones y alertas ---------- */
.auth-error, .auth-success { animation: arvia-slide .3s var(--a-ease) both }
.bell-badge, .notif-count { animation: arvia-pop .4s var(--a-ease-spring) both }

@media (max-width: 1100px) {
    .crm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) }
}
@media (max-width: 720px) {
    .crm-grid { grid-template-columns: 1fr }
    .crm-wide { grid-column: auto }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) }
    .kpi-value { font-size: 1.6rem }
    .crm-filter select { min-width: 0; width: 100% }
    .crm-filter { width: 100% }
}

/* ---------- Modo oscuro ---------- */
html[data-theme="dark"] .sidebar-brand, html[data-theme="dark"] .navbar-brand span, html[data-theme="dark"] .footer-brand span, html[data-theme="dark"] .mobile-topbar strong { color: #E5EDF7 !important }
html[data-theme="dark"] {
    --a-ink: #E5EDF7; --a-ink-2: #C9D6E5; --a-muted: #9FB0C6; --a-line: #27364F; --a-card: #111A2B; --a-bg: #0B1220;
    --a-teal-soft: #0B3A47;
    --a-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --a-shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 16px 36px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] .nav-group-title:hover { background: #17233A }
html[data-theme="dark"] .nav-group[open] > .nav-group-title { color: #5EC8DB }
html[data-theme="dark"] .nav-item.active::before { background: #5EC8DB }
html[data-theme="dark"] .pill-ok { background: #064E3B; color: #6EE7B7 }
html[data-theme="dark"] .pill-info { background: #0B3A47; color: #7DD3E4 }
html[data-theme="dark"] .pill-warn { background: #451A03; color: #FCD34D }
html[data-theme="dark"] .pill-muted, html[data-theme="dark"] .pill { background: #1E293B; color: #CBD5E1 }
html[data-theme="dark"] .bar { background: #2B7A8C }
html[data-theme="dark"] .bar.today, html[data-theme="dark"] .bar-slot:hover .bar { background: #5EC8DB }
html[data-theme="dark"] .bar-slot::after { background: #E5EDF7; color: #0B1220 }
html[data-theme="dark"] .crm-table td { border-color: #1C2940 }
html[data-theme="dark"] .crm-table tbody tr:hover, html[data-theme="dark"] .crm-table tr.sel { background: #0F2A33 }
html[data-theme="dark"] .meter { background: #1C2940 }
html[data-theme="dark"] .meter > div { background: #5EC8DB }
html[data-theme="dark"] .trend.up { color: #6EE7B7 }
html[data-theme="dark"] .trend.down { color: #FCA5A5 }
html[data-theme="dark"] .custody-choice label:has(input:checked) { background: #0F2A33; border-color: #5EC8DB }
html[data-theme="dark"] .quick-actions .qa { color: #7DD3E4 }
html[data-theme="dark"] .quick-actions .qa:first-child { background: #0E7490; color: #fff }
html[data-theme="dark"] a.stat-card:hover, html[data-theme="dark"] .pet-card:hover, html[data-theme="dark"] a.kpi:hover { border-color: #2B7A8C }

/* ---------- Celebraciones ---------- */
.celebrate { position: relative; display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, #ECFEFF, #F0FDF4); border: 1px solid #A5F3FC; border-radius: 16px; padding: 14px 18px; margin-bottom: 18px; overflow: hidden; animation: arvia-pop .5s var(--a-ease-spring) both }
.celebrate b { display: block; color: var(--a-ink); font-size: 16px }
.celebrate small { color: var(--a-muted) }
.celebrate-emoji { font-size: 34px; animation: arvia-wiggle .8s ease 2 }
.confetti-piece { position: fixed; top: -12px; width: 9px; height: 14px; border-radius: 2px; z-index: 9999; pointer-events: none; animation: arvia-fall linear forwards }
@keyframes arvia-fall { to { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); opacity: .9 } }
html[data-theme="dark"] .celebrate { background: linear-gradient(135deg, #0F2A33, #0E2A1F); border-color: #2B7A8C }

/* ---------- Modo amigable para menores (control parental) ---------- */
body.kid { --a-teal: #0EA5A4; }
body.kid .nav-item.active { background: linear-gradient(135deg, #14B8A6, #0EA5E9) !important; border-radius: 16px !important }
body.kid .form-card, body.kid .stat-card, body.kid .pet-card, body.kid .kpi { border-radius: 20px }
body.kid .btn-add-pet { border-radius: 99px; padding: 12px 22px }
body.kid .btn-add-pet:hover { transform: translateY(-2px) scale(1.03) }
body.kid .pet-card:hover { transform: translateY(-4px) rotate(-.6deg) }
body.kid .sidebar-logo { animation: arvia-wiggle 1.2s ease 1 }
body.kid .dashboard-header h1::after { content: " 🐾"; display: inline-block; animation: arvia-pop .6s var(--a-ease-spring) .2s both }
.kid-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: linear-gradient(135deg, #FEF9C3, #DCFCE7); border: 1px solid #FDE68A; border-radius: 18px; padding: 14px 18px; margin-bottom: 18px; animation: arvia-rise .5s var(--a-ease) both }
.kid-banner > div { flex: 1; min-width: 200px }
.kid-banner b { display: block; color: #713F12 }
.kid-banner small { color: #854D0E }
.kid-banner-paw { font-size: 30px; animation: arvia-wiggle 1.4s ease-in-out infinite }
.kid-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; background: linear-gradient(135deg, #ECFEFF, #FDF4FF); border-radius: 22px; padding: 18px 20px; margin-bottom: 18px }
.kid-hero h2 { margin: 0 0 4px; font-size: 1.2rem; color: var(--a-ink) }
.kid-hero p { margin: 0; color: var(--a-muted) }
.kid-hero-art { font-size: 38px; display: flex; gap: 6px }
.kid-hero-art span, .minor-art span { display: inline-block; animation: arvia-bob 2.4s ease-in-out infinite }
.kid-hero-art span:nth-child(2), .minor-art span:nth-child(2) { animation-delay: .3s }
.kid-hero-art span:nth-child(3), .minor-art span:nth-child(3) { animation-delay: .6s }
@keyframes arvia-bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
html[data-theme="dark"] .kid-banner { background: linear-gradient(135deg, #33270D, #0E2A1F); border-color: #78350F }
html[data-theme="dark"] .kid-banner b, html[data-theme="dark"] .kid-banner small { color: #FDE68A }
html[data-theme="dark"] .kid-hero { background: linear-gradient(135deg, #0F2A33, #2A1033) }

.minor-box { background: linear-gradient(135deg, #ECFEFF, #F0FDF4); border: 1px solid #A5F3FC; border-radius: 16px; padding: 14px 16px; margin: 6px 0 12px; animation: arvia-pop .45s var(--a-ease-spring) both }
.minor-box p { font-size: 13px; color: #475569; margin: 4px 0 10px }
.minor-art { font-size: 28px; display: flex; gap: 6px; margin-bottom: 4px }
html[data-theme="dark"] .minor-box { background: #0F2A33; border-color: #2B7A8C }
html[data-theme="dark"] .minor-box p { color: #9FB0C6 }

/* ---------- Unidad familiar ---------- */
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px }
.family-card { display: flex; align-items: center; gap: 12px; background: var(--a-card); border: 1px solid var(--a-line); border-radius: 16px; padding: 14px; box-shadow: var(--a-shadow) }
.family-card.pending { border-style: dashed; opacity: .85 }
.family-card form { margin: 0 }
.link-btn { background: none; border: 0; color: #B91C1C; font-weight: 600; cursor: pointer; font-size: 13px }

/* ---------- Foto de perfil ---------- */
.user-avatar { overflow: hidden; flex-shrink: 0; background: linear-gradient(135deg, #155E75, #13A8AA) !important }
.user-avatar img, .avatar img, .topbar-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50% }
.sidebar-person:hover .user-avatar { transform: scale(1.06); transition: transform .25s var(--a-ease-spring) }
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: linear-gradient(135deg, #155E75, #13A8AA); color: #fff; font-size: 13px; font-weight: 700; text-decoration: none; box-shadow: 0 0 0 2px var(--a-card), 0 0 0 4px #A5F3FC; transition: transform .2s var(--a-ease-spring) }
.topbar-avatar:hover { transform: scale(1.08) }
.mobile-topbar .topbar-avatar { margin-left: 4px }
.avatar { overflow: visible }
.avatar i { z-index: 1 }
.avatar img { position: absolute; inset: 0 }

/* ---------- Reducir movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important }
    .js .reveal { opacity: 1; transform: none }
}

/* ---------- Bloques repetibles de formularios (insumos, receta, exámenes, vacunas, archivos) ---------- */
:root { --row-bg: #F8FBFC; --row-line: #E2E8F0; --row-hover: #A5D8E3; --row-focus: rgba(14, 116, 144, .14); --row-rm: #B91C1C; --row-rm-bg: #FEF2F2; --add-ink: var(--primary, #0E7490); --add-line: #CBD5E1; --add-hover-bg: #ECFEFF; }
html[data-theme="dark"] { --row-bg: #0F1A2C; --row-line: #27364F; --row-hover: #2B7A8C; --row-focus: rgba(94, 200, 219, .18); --row-rm: #FCA5A5; --row-rm-bg: #3B1A1F; --add-ink: #5EC8DB; --add-line: #34466A; --add-hover-bg: #0E2A33; }

.rowbox {
    position: relative; margin-bottom: 12px; padding: 14px; border: 1px solid var(--row-line); border-radius: 14px;
    background: var(--row-bg); color: var(--a-ink, inherit);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .25s ease, opacity .25s ease, transform .25s ease,
                max-height .3s ease, padding .3s ease, margin .3s ease;
    animation: rowIn .32s cubic-bezier(.2, .8, .2, 1);
}
.rowbox:hover { border-color: var(--row-hover); }
.rowbox:focus-within { border-color: var(--row-hover); box-shadow: 0 0 0 3px var(--row-focus); }
.rowbox input, .rowbox select, .rowbox textarea { width: 100%; box-sizing: border-box; transition: border-color .15s ease, box-shadow .15s ease, background-color .25s ease; }
.rowbox label { color: var(--a-ink-2, #334155); }
.rowbox .rm {
    position: absolute; top: 6px; right: 8px; padding: 4px 9px; border: none; border-radius: 8px; background: none;
    color: var(--row-rm); font-size: 13px; cursor: pointer; transition: background-color .15s ease, transform .15s ease;
}
.rowbox .rm:hover { background: var(--row-rm-bg); }
.rowbox .rm:active { transform: scale(.94); }
.row-anim { animation: rowIn .32s cubic-bezier(.2, .8, .2, 1); transition: opacity .25s ease, transform .25s ease, max-height .3s ease, margin .3s ease; }
.rowbox.leaving, .row-anim.leaving { opacity: 0; transform: translateY(-6px) scale(.98); max-height: 0 !important; padding-top: 0; padding-bottom: 0; margin-bottom: 0; border-width: 0; overflow: hidden; pointer-events: none; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-8px) scale(.985); } to { opacity: 1; transform: none; } }

.btn-addrow, .pkg-quick {
    font: inherit; font-weight: 600; font-size: 14px; color: var(--add-ink); background: transparent; cursor: pointer;
    border: 1.5px dashed var(--add-line); border-radius: 12px;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease, transform .15s ease, box-shadow .18s ease;
}
.btn-addrow { display: block; width: 100%; padding: 12px 14px; margin-bottom: 8px; }
.pkg-quick { padding: 8px 12px; border-style: solid; border-width: 1px; }
.btn-addrow:hover, .pkg-quick:hover { border-color: var(--add-ink); background: var(--add-hover-bg); transform: translateY(-1px); }
.btn-addrow:active, .pkg-quick:active { transform: translateY(0) scale(.99); }
.btn-addrow:focus-visible, .pkg-quick:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--row-focus); }
.pkg-quick.added { animation: pkgPulse .5s ease; }
@keyframes pkgPulse { 40% { background: var(--add-hover-bg); border-color: var(--add-ink); transform: scale(1.04); } }

/* Botones con color de marca escrito en style="..." : en oscuro el turquesa oscuro no se lee */
html[data-theme="dark"] [style*="color:var(--primary)" i], html[data-theme="dark"] [style*="color: var(--primary)" i] { color: #5EC8DB !important; }

@media (prefers-reduced-motion: reduce) {
    .rowbox, .row-anim, .btn-addrow, .pkg-quick, .rowbox .rm { animation: none !important; transition: none !important; }
}
html[data-theme="dark"] .a-low { background: #3A2F0B; color: #FCD34D; }
html[data-theme="dark"] .a-exp { background: #3B2310; color: #FDBA74; }
html[data-theme="dark"] .a-dead { background: #3B1A1F; color: #FCA5A5; }

/* Selector segmentado (Inmediato / Programado) y piezas de las órdenes */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 12px; background: var(--row-line); margin-bottom: 4px; }
.seg label { margin: 0 !important; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--a-muted, #64748B);
    transition: background-color .2s ease, color .2s ease, box-shadow .2s ease; }
.seg input:checked + span { background: var(--a-card, #fff); color: var(--add-ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px var(--row-focus); }
.rowbox .sched { animation: rowIn .28s cubic-bezier(.2, .8, .2, 1); }
.rowbox .check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; margin: 10px 0 2px; }
.rowbox .check input { width: auto !important; margin-top: 3px; }
.rowbox .hint { display: block; min-height: 1em; margin-top: 3px; font-size: 12px; color: #B45309; }
html[data-theme="dark"] .rowbox .hint { color: #FCD34D; }
.prep-preview { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--add-hover-bg); color: var(--a-ink, #0F172A); font-size: 13px; border-left: 3px solid var(--add-ink); animation: rowIn .25s ease; }
input.bump { animation: bump .5s ease; }
@keyframes bump { 30% { box-shadow: 0 0 0 4px rgba(245, 158, 11, .35); border-color: #F59E0B; } }
@media (prefers-reduced-motion: reduce) { .rowbox .sched, .prep-preview, input.bump { animation: none !important; } .seg span { transition: none !important; } }

/* Actualización en vivo */
.live-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--a-muted, #64748B); white-space: nowrap; }
.live-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #94A3B8; }
.live-status.ok::before { background: #10B981; animation: livePulse 2s ease-in-out infinite; }
.live-status.bad::before { background: #F59E0B; }
@keyframes livePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); } 50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); } }
.live-new { animation: liveIn .6s cubic-bezier(.2, .8, .2, 1); }
@keyframes liveIn { 0% { opacity: 0; transform: translateY(-6px) scale(.97); box-shadow: 0 0 0 3px rgba(94, 200, 219, .7); } 60% { opacity: 1; transform: none; } 100% { box-shadow: 0 0 0 0 rgba(94, 200, 219, 0); } }
[data-live-refresh] { cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .live-status.ok::before, .live-new { animation: none !important; } }

/* Progreso de la visita para el tutor */
.owner-live:not(:empty) { margin-bottom: 22px; }
.visit-live { display: block; text-decoration: none; color: var(--a-ink, #0F172A); background: var(--a-card, #fff); border: 1px solid var(--a-line, #E2E8F0);
    border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--a-shadow, 0 1px 2px rgba(15, 23, 42, .06));
    transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; }
a.visit-live:hover { transform: translateY(-1px); box-shadow: var(--a-shadow-lift, 0 8px 24px rgba(15, 23, 42, .12)); border-color: var(--row-hover); }
.visit-live .vl-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.visit-live .vl-head strong { font-size: 15px; }
.visit-live .vl-head span { font-size: 12px; color: var(--a-muted, #64748B); }
.vl-bar { height: 6px; border-radius: 99px; background: var(--row-line); margin: 12px 0 10px; overflow: hidden; }
.vl-bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #0E7490, #14B8A6); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.vl-steps { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; overflow-x: auto; }
.vl-steps li { flex: 1 0 92px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-size: 12px; color: var(--a-muted, #64748B); }
.vl-steps .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--add-line); background: transparent; transition: background-color .3s ease, border-color .3s ease; }
.vl-steps li.done { color: var(--a-ink, #0F172A); }
.vl-steps li.done .dot { background: #14B8A6; border-color: #14B8A6; }
.vl-steps li.current { color: var(--add-ink); font-weight: 700; }
.vl-steps li.current .dot { border-color: var(--add-ink); background: var(--add-hover-bg); animation: stepPulse 1.6s ease-in-out infinite; }
.vl-steps small { color: var(--a-muted, #64748B); font-weight: normal; }
@keyframes stepPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(14, 116, 144, .45); } 50% { box-shadow: 0 0 0 6px rgba(14, 116, 144, 0); } }
.vl-vitals { margin-top: 8px; font-size: 12px; color: var(--a-muted, #64748B); }
.visit-live.prog { border-left: 4px solid #6366F1; }
.visit-live.prog.surgery { border-left-color: #DB2777; }
.visit-live.prog.procedure { border-left-color: #0EA5E9; }
.vl-prep-title { margin-top: 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--a-muted, #64748B); }
.vl-prep { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.vl-prep li { margin: 2px 0; }
@media (prefers-reduced-motion: reduce) { .vl-steps li.current .dot { animation: none; } .vl-bar > div, a.visit-live { transition: none; } }

/* ---------- Formularios de configuración ---------- */
.set-h { margin: 22px 0 2px; font-size: 1rem; color: var(--a-ink) }
.set-sub { margin: 0 0 8px; font-size: 13px; color: var(--a-muted) }
.set-hint { display: block; font-size: 12.5px; line-height: 1.4; color: var(--a-muted); margin: 7px 0 12px }
.hc-help { display: grid; gap: 4px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: #F0FDFA; border: 1px solid #A5F3FC; font-size: 13px }
.hc-help a { color: #0E7490; font-weight: 600 }
.hc-help small { color: var(--a-muted) }
html[data-theme="dark"] .hc-help { background: #0F2A33; border-color: #2B7A8C }
html[data-theme="dark"] .hc-help a { color: #5EC8DB }
.svc-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end }
.svc-edit { display: inline-block; margin-right: 8px }
.svc-edit > summary { cursor: pointer; color: #0E7490; font-weight: 600; font-size: 13px; list-style: none }
.svc-edit[open] > form { position: absolute; z-index: 5; right: 16px; width: min(560px, calc(100vw - 48px)); background: var(--a-card); border: 1px solid var(--a-line); border-radius: 14px; padding: 14px; box-shadow: var(--a-shadow-lift); animation: arvia-slide .2s var(--a-ease) both }
.crm-table-wrap { position: relative }

/* ---------- Prioridad de atención (siempre con texto) ---------- */
.prio-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 6px 0 12px }
.prio-choice label { display: flex; gap: 8px; align-items: flex-start; border: 1.5px solid var(--a-line); border-left-width: 5px; border-radius: 12px; padding: 8px 10px; cursor: pointer; transition: transform .2s var(--a-ease), background .2s ease }
.prio-choice label:hover { transform: translateY(-1px) }
.prio-choice input { width: auto !important; margin-top: 3px }
.prio-choice span { display: flex; flex-direction: column }
.prio-choice small { font-size: 11px; color: var(--a-muted) }
.prio-choice .prio-normal { border-left-color: #94A3B8 }
.prio-choice .prio-quick { border-left-color: #0EA5E9 }
.prio-choice .prio-high { border-left-color: #F59E0B }
.prio-choice .prio-emergency { border-left-color: #DC2626 }
.prio-choice label:has(input:checked) { background: #F0FDFA; border-color: #0E7490 }
.prio-choice .prio-emergency:has(input:checked) { background: #FEF2F2; border-color: #DC2626 }
.prio-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 2px 8px; vertical-align: middle }
.prio-badge.prio-emergency { background: #DC2626; color: #fff; animation: arvia-pulse-red 1.6s infinite }
.prio-badge.prio-emergency::before { content: "🚨" }
.prio-badge.prio-high { background: #FEF3C7; color: #92400E }
.prio-badge.prio-quick { background: #E0F2FE; color: #0369A1 }
.prio-badge.prio-quick::before { content: "⚡" }
@keyframes arvia-pulse-red { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .5) } 70% { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0) } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0) } }
.prio-inline select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--a-line); font-size: 12px; background: var(--a-card); color: var(--a-ink) }
html[data-theme="dark"] .prio-choice label:has(input:checked) { background: #0F2A33 }
html[data-theme="dark"] .prio-choice .prio-emergency:has(input:checked) { background: #3A1418 }
html[data-theme="dark"] .prio-badge.prio-high { background: #451A03; color: #FCD34D }
html[data-theme="dark"] .prio-badge.prio-quick { background: #0B3A47; color: #7DD3E4 }

/* Ayudas debajo de los campos: siempre con aire, nunca encima de la caja. */
.form-card input + small, .form-card select + small, .form-card textarea + small,
.form-card .ui-pw + small, .cj-form input + small, .form-card input + .field-error { display: block; margin-top: 7px !important; line-height: 1.4; }
.form-card label { margin-top: 16px; }
.form-card .grid-2 > div > label:first-child, .form-card .grid-3 > div > label:first-child { margin-top: 12px; }

/* Movimiento en listas y tarjetas (caja, equipo, laboratorio, inventario, cobros…). */
.cj-list > *, .appointment-card, .inv-row, .tm-member, .rowbox { animation: arvia-rise .42s var(--a-ease) both }
.cj-list > *:nth-child(2), .tm-member:nth-of-type(2) { animation-delay: .04s }
.cj-list > *:nth-child(3), .tm-member:nth-of-type(3) { animation-delay: .08s }
.cj-list > *:nth-child(4), .tm-member:nth-of-type(4) { animation-delay: .12s }
.cj-list > *:nth-child(n+5), .tm-member:nth-of-type(n+5) { animation-delay: .16s }
.cj-kpi:nth-child(2) { animation-delay: .05s } .cj-kpi:nth-child(3) { animation-delay: .1s } .cj-kpi:nth-child(4) { animation-delay: .15s }
.cj-lines tbody tr, .inv table tr, .gn-rel tbody tr { animation: arvia-fade .4s ease both }
.cj-method[open] > *:not(summary), details[open] > form { animation: arvia-slide .25s var(--a-ease) both }
.form-card input:focus, .form-card select:focus, .form-card textarea:focus, .cj-form input:focus, .cj-form select:focus {
    outline: none; border-color: #155E75 !important; box-shadow: 0 0 0 3px rgba(21, 94, 117, .15); transition: box-shadow .2s ease, border-color .2s ease }
.btn-add-pet, .cj-btn-sm, .btn-login { transition: transform .15s ease, box-shadow .2s ease, filter .2s ease }
.btn-add-pet:hover, .btn-login:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(21, 94, 117, .22) }
.btn-add-pet:active, .cj-btn-sm:active, .btn-login:active { transform: scale(.98) }
.cj-st { animation: arvia-pop .35s var(--a-ease-spring) both }
@media (prefers-reduced-motion: reduce) {
    .cj-list > *, .appointment-card, .inv-row, .tm-member, .rowbox, .cj-lines tbody tr, .inv table tr, .gn-rel tbody tr, .cj-st { animation: none !important }
    .btn-add-pet:hover, .btn-login:hover { transform: none }
}
.form-card .grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; } @media (max-width: 700px) { .form-card .grid-3 { grid-template-columns: 1fr; } }
.kid-hero-art img, .minor-art img, .art img { width: 54px; height: 54px; border-radius: 50%; margin: 0 4px; display: inline-block; animation: arvia-bob 2.4s ease-in-out infinite; box-shadow: 0 6px 14px rgba(15,23,42,.12) }
.kid-hero-art img:nth-child(2), .minor-art img:nth-child(2), .art img:nth-child(2) { animation-delay: .3s }
.kid-hero-art img:nth-child(3), .minor-art img:nth-child(3), .art img:nth-child(3) { animation-delay: .6s }
