/* ══════════════════════════════════════════════════════════════════
   Appointily · Sistema de filtros
   ──────────────────────────────────────────────────────────────────
   Estilos de AppointifySmartSelect, AppointifyDateRange,
   AppointifySearch y AppointifyFilters (appointily-filters.js).
   Solo tokens de appointily-tokens.css: funciona en claro y oscuro.

     1. Disparador (.af-select / .af-trigger)
     2. Menú flotante (.af-menu) y opciones (.af-opt)
     3. Calendario de rango (.af-dates / .af-cal)
     4. Búsqueda (.af-search)
     5. Barra de filtros (.af-filters), chips y hoja inferior
     6. Skeleton y animaciones
   ══════════════════════════════════════════════════════════════════ */

.af-native {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important;
    overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important; border: 0 !important;
}

/* ── 1. Disparador ─────────────────────────────────────────────── */
.af-select { position: relative; min-width: 0; }

.af-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    margin: 0;
    padding: 8px 12px 8px 9px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    color: var(--color-text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color var(--motion-base) var(--ease-out),
                box-shadow var(--motion-base) var(--ease-out),
                background-color var(--motion-base) var(--ease-out);
}
.af-trigger:hover { border-color: var(--color-border-input); }
.af-trigger:focus-visible,
.af-select.is-open > .af-trigger {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}
.af-trigger:disabled { cursor: not-allowed; opacity: .55; }

.af-trigger__lead {
    width: 34px; height: 34px;
    flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: var(--radius-md);
    background: var(--color-surface-sunken);
    color: var(--color-text-secondary);
    font-size: 18px;
    transition: background-color var(--motion-base) var(--ease-out), color var(--motion-base) var(--ease-out), transform var(--motion-base) var(--ease-out);
}
.af-trigger__lead:empty { display: none; }
.af-trigger__lead:has(.af-avatar),
.af-trigger__lead:has(.af-dot) { background: transparent; }
.af-trigger__lead .af-avatar { width: 32px; height: 32px; font-size: 11px; }

.af-trigger__text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.af-trigger__label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--color-text-muted);
}
.af-trigger__value {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.af-trigger__count {
    flex-shrink: 0;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}
.af-trigger__count[hidden] { display: none; }
.af-trigger__end { display: grid; place-items: center; width: 18px; flex-shrink: 0; color: var(--color-text-muted); }
.af-trigger__chev { font-size: 16px; transition: transform var(--motion-base) var(--ease-out); }
.af-select.is-open .af-trigger__chev { transform: rotate(180deg); color: var(--color-primary-text); }
.af-select--date .af-trigger__chev { display: none; }

/* Valor distinto del predeterminado: borde de marca + punto azul */
.af-select.is-active > .af-trigger { border-color: var(--color-primary-border); }
.af-select.is-active .af-trigger__lead { background: var(--color-primary-subtle); color: var(--color-primary-text); }
.af-select.is-active .af-trigger__lead:has(.af-avatar),
.af-select.is-active .af-trigger__lead:has(.af-dot) { background: transparent; }
.af-select.is-active .af-trigger__value { color: var(--color-primary-text); }
.af-select.is-active .af-trigger__label::after {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: afDotIn var(--motion-slow) var(--ease-out);
}
.af-select.is-placeholder .af-trigger__value { color: var(--color-text-muted); font-weight: var(--weight-regular); }
.af-select.is-changed .af-trigger__lead { animation: afPop var(--motion-slow) var(--ease-out); }

/* Carga y botón quitar */
.af-spinner {
    display: none;
    width: 14px; height: 14px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: afSpin .7s linear infinite;
}
.af-select.is-loading .af-spinner { display: block; }
.af-select.is-loading .af-trigger__chev { display: none; }
.af-select.is-loading > .af-trigger { cursor: progress; }

.af-trigger__clear {
    position: absolute; top: 50%; right: 34px;
    transform: translateY(-50%);
    width: 26px; height: 26px;
    display: grid; place-items: center;
    padding: 0; border: 0; border-radius: 50%;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 16px;
    cursor: pointer;
}
.af-trigger__clear:hover { color: var(--color-text-primary); }
.af-trigger__clear:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.af-trigger__clear[hidden] { display: none; }
.af-select:has(.af-trigger__clear:not([hidden])) > .af-trigger { padding-right: 40px; }

/* Variante «campo»: formularios con <label> propio; misma altura que los inputs */
.af-select--field > .af-trigger {
    min-height: var(--field-height-md);
    gap: 8px;
    padding: 6px 12px;
    border-color: var(--color-border-input);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.af-select--field > .af-trigger:hover { border-color: var(--color-text-muted); }
.af-select--field > .af-trigger:focus-visible,
.af-select--field.is-open > .af-trigger { border-color: var(--color-primary); }
.af-select--field .af-trigger__lead { width: auto; height: auto; background: transparent; font-size: 16px; }
.af-select--field .af-trigger__lead .af-avatar { width: 24px; height: 24px; font-size: 9.5px; }
.af-select--field .af-trigger__value { font-weight: var(--weight-regular); }
.af-select--field.is-placeholder .af-trigger__value { color: var(--color-text-muted); }
.af-select--field.is-active > .af-trigger { border-color: var(--color-primary-border); background: var(--color-primary-subtle); }
.af-select--field.is-active .af-trigger__lead { background: transparent; }
.af-select--field.is-active .af-trigger__value { font-weight: var(--weight-semibold); }

.af-select--sm > .af-trigger { min-height: var(--field-height-sm); padding: 4px 10px; }
.af-select--sm .af-trigger__value { font-size: var(--text-sm); }
.af-select--lg > .af-trigger { min-height: var(--field-height-lg); }

/* Disposición heredada del <select>: en línea (p. ej. «Mostrar 10 registros») o ancho propio en barras flex */
.af-select--inline { display: inline-block; width: auto; min-width: 84px; vertical-align: middle; }
.af-select--auto { width: auto; flex: 0 0 auto; }
.af-select[hidden] { display: none !important; }
.af-select > .af-native { left: 12px; bottom: 0; }

/* Icono del campo (p. ej. el absorbido de un .input-group): atenuado; de marca con el foco */
.af-select--field .af-trigger__lead { color: var(--color-text-muted); font-size: 18px; }
.af-select--field > .af-trigger:focus-visible .af-trigger__lead,
.af-select--field.is-open .af-trigger__lead { color: var(--color-primary-text); }

/* Dentro de .input-group: ocupa el ancho disponible como un .form-select */
.input-group > .af-select--in-group { position: relative; flex: 1 1 auto; width: 1%; min-width: 0; margin-left: 0; }
.input-group > .af-absorbed { display: none !important; }
:root:not(#_) .input-group.af-input-group:focus-within { box-shadow: none; }
.af-select--in-group.af-join-start > .af-trigger { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; }
.af-select--in-group.af-join-end > .af-trigger { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }

/* Validación */
.af-select.is-invalid > .af-trigger,
.was-validated .af-select:has(> .af-native:invalid) > .af-trigger { border-color: var(--color-error); }
.af-select.is-invalid > .af-trigger:focus-visible,
.af-select.is-invalid.is-open > .af-trigger { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-error) 22%, transparent); }
.af-select.is-valid > .af-trigger { border-color: var(--color-success); }
.af-select__error {
    display: flex; align-items: center; gap: 6px;
    margin-top: 6px;
    font-size: var(--text-sm);
    color: var(--color-error);
    animation: afFadeIn var(--motion-base) var(--ease-out);
}
.af-select > .invalid-feedback { margin-top: 6px; }

/* Deshabilitado y solo lectura (un único valor posible, p. ej. una sola sucursal) */
.af-select--field > .af-trigger:disabled { opacity: 1; background: var(--color-surface-sunken); color: var(--color-text-disabled); }
.af-select--field > .af-trigger:disabled .af-trigger__value { color: var(--color-text-disabled); }
.af-select.is-readonly > .af-trigger { pointer-events: none; background: var(--color-surface-sunken); }
.af-select.is-readonly .af-trigger__chev { display: none; }

/* Avatar y punto de estado */
.af-avatar {
    width: 28px; height: 28px;
    flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 50%;
    overflow: hidden;
    font-size: 10.5px;
    font-weight: var(--weight-bold);
    letter-spacing: .02em;
}
.af-avatar img { width: 100%; height: 100%; object-fit: cover; }
.af-avatar iconify-icon { font-size: 16px; }
.af-tone-0   { background: var(--color-primary-subtle);  color: var(--color-primary-text); }
.af-tone-1   { background: var(--color-accent-subtle);   color: var(--color-accent-text); }
.af-tone-2   { background: var(--color-surface-sunken);  color: var(--color-text-secondary); }
.af-tone-3   { background: var(--color-primary);         color: var(--color-on-primary); }
.af-tone-4   { background: var(--color-secondary);       color: var(--color-on-secondary); }
.af-tone-5   { background: var(--color-inverse);         color: var(--color-on-inverse); }
.af-tone-all { background: var(--color-surface-sunken);  color: var(--color-text-secondary); }

.af-dot {
    width: 10px; height: 10px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--af-dot, var(--color-text-muted));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--af-dot, currentColor) 18%, transparent);
}
.af-trigger__lead .af-dot { width: 11px; height: 11px; }
.af-emoji { font-size: 17px; line-height: 1; }
.af-trigger__lead:has(.af-emoji) { background: transparent; }


/* ── 2. Menú flotante ──────────────────────────────────────────── */
.af-menu {
    position: fixed;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    max-height: var(--af-avail, 380px);
    overflow: hidden;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: var(--shadow-md), var(--shadow-xs);
    color: var(--color-text-primary);
    font-size: var(--text-base);
    opacity: 0;
    transform: translateY(-6px) scale(.985);
    transform-origin: top center;
    transition: opacity var(--motion-base) var(--ease-out), transform var(--motion-base) var(--ease-out);
}
.af-menu.is-up { transform: translateY(6px) scale(.985); transform-origin: bottom center; }
.af-menu.is-open { opacity: 1; transform: none; }
.af-menu[hidden] { display: none !important; }

.af-menu__head { display: none; }

.af-menu__search {
    position: relative;
    flex-shrink: 0;
    padding: 8px;
    border-bottom: 1px solid var(--color-border);
}
.af-menu:not(.has-search) .af-menu__search { display: none; }
.af-menu__search iconify-icon {
    position: absolute; left: 20px; top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 16px;
    pointer-events: none;
}
.af-menu__search input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--color-surface-sunken);
    color: var(--color-text-primary);
    font: inherit;
    font-size: var(--text-base);
    outline: none;
    transition: border-color var(--motion-fast), background-color var(--motion-fast);
}
.af-menu__search input::placeholder { color: var(--color-text-muted); }
.af-menu__search input:focus { border-color: var(--color-primary-border); background: var(--color-surface); }

.af-menu__list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    outline: none;
    scrollbar-width: thin;
}

.af-group {
    padding: 10px 10px 4px;
    font-size: 11px;
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.af-opt {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}
.af-opt + .af-opt.is-all,
.af-opt.is-all { margin-bottom: 2px; }
.af-opt.is-all::after {
    content: '';
    position: absolute; left: 10px; right: 10px; bottom: -2px;
    height: 1px;
    background: var(--color-border);
}
.af-opt.is-focused { background: var(--color-surface-sunken); }
.af-menu:focus-within .af-opt.is-focused { box-shadow: inset 2px 0 0 var(--color-primary); }
.af-opt[aria-selected="true"] { background: var(--color-surface-selected); color: var(--color-primary-text); }
.af-opt[aria-selected="true"] .af-opt__label { font-weight: var(--weight-semibold); }
.af-opt.is-disabled { opacity: .45; cursor: not-allowed; }

.af-opt__lead { display: grid; place-items: center; width: 28px; flex-shrink: 0; font-size: 18px; color: var(--color-text-secondary); }
.af-opt[aria-selected="true"] .af-opt__lead { color: var(--color-primary-text); }
.af-opt__text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.af-opt__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.af-opt__label mark,
.af-opt__desc mark { padding: 0; background: none; color: var(--color-primary-text); font-weight: var(--weight-bold); }
.af-opt__desc { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.af-opt__badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-sunken);
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: var(--weight-semibold);
}

/* Check animado (trazo que se dibuja) */
.af-opt__check { display: grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0; margin-left: auto; color: var(--color-primary-text); }
.af-opt__check svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.af-opt__check path { stroke-dasharray: 16; stroke-dashoffset: 16; transition: stroke-dashoffset 220ms var(--ease-out); }
.af-opt[aria-selected="true"] .af-opt__check path { stroke-dashoffset: 0; }

/* Selección múltiple: casilla */
.af-opt.is-multi .af-opt__check {
    order: -1;
    margin-left: 0;
    border: 1.5px solid var(--color-border-input);
    border-radius: 5px;
    transition: background-color var(--motion-fast), border-color var(--motion-fast);
}
.af-opt.is-multi .af-opt__check svg { width: 12px; height: 12px; stroke-width: 2.6; }
.af-opt.is-multi[aria-selected="true"] .af-opt__check { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }

.af-menu__status:empty { display: none; }
.af-menu__empty {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 22px 16px 26px;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    text-align: center;
}
.af-menu__empty iconify-icon { font-size: 26px; opacity: .6; }

.af-menu__foot {
    display: flex; justify-content: space-between; gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--color-border);
}

.af-skel-opt { display: flex; align-items: center; gap: 10px; padding: 10px; }

/* Móvil: hoja inferior */
.af-backdrop {
    position: fixed; inset: 0;
    z-index: 1089;
    background: var(--color-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-slow) var(--ease-out);
}
.af-backdrop.is-visible { opacity: 1; pointer-events: auto; }

.af-menu.is-sheet {
    top: auto !important; left: 0 !important; right: 0; bottom: 0;
    width: auto !important;
    max-height: 80vh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: var(--shadow-lg);
    transform: translateY(24px);
    transition-duration: var(--motion-slow);
}
.af-menu.is-sheet.is-open { transform: none; }
.af-menu.is-sheet .af-menu__head {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 8px 16px 6px;
    flex-shrink: 0;
}
.af-menu__grab { width: 38px; height: 4px; border-radius: 4px; background: var(--color-border-strong); }
.af-menu__title { align-self: flex-start; font-size: var(--text-md); font-weight: var(--weight-bold); }
.af-menu.is-sheet .af-menu__search { border-bottom: 0; padding: 4px 12px 8px; }
.af-menu.is-sheet .af-menu__search iconify-icon { left: 24px; }
.af-menu.is-sheet .af-menu__search input { height: 44px; font-size: 16px; } /* 16px evita el zoom de iOS */
.af-menu.is-sheet .af-menu__list { padding: 4px 10px 12px; }
.af-menu.is-sheet .af-opt { min-height: 50px; padding: 9px 12px; }


/* ── 3. Calendario de rango ────────────────────────────────────── */
.af-dates { display: flex; min-height: 0; overflow: auto; }
.af-dates__presets {
    display: flex; flex-direction: column; gap: 2px;
    width: 168px; flex-shrink: 0;
    padding: 10px 8px;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface-sunken);
}
.af-preset {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 0; border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast);
}
.af-preset:hover { background: var(--color-surface); color: var(--color-text-primary); }
.af-preset[aria-pressed="true"] { background: var(--color-surface); color: var(--color-primary-text); font-weight: var(--weight-semibold); box-shadow: var(--shadow-xs), inset 2px 0 0 var(--color-primary); }
.af-preset:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.af-preset iconify-icon { font-size: 14px; }

.af-cal { flex: 1; min-width: 0; padding: 12px 14px 10px; }
.af-cal__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.af-cal__title { font-weight: var(--weight-semibold); font-size: var(--text-base); }
.af-cal__nav {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface); color: var(--color-text-secondary);
    font-size: 16px; cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast);
}
.af-cal__nav:hover { background: var(--color-surface-sunken); color: var(--color-text-primary); }
.af-cal__nav:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.af-cal__hint { margin: 4px 0 6px; font-size: var(--text-xs); color: var(--color-text-muted); text-align: center; }

.af-cal__row { display: grid; grid-template-columns: repeat(7, 1fr); }
.af-cal__row + .af-cal__row { margin-top: 2px; }
.af-cal__dow span { display: grid; place-items: center; height: 26px; font-size: 11px; font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.af-cal__row > span { display: block; }

.af-day {
    position: relative;
    width: 100%; height: 36px;
    padding: 0; border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-primary);
    font: inherit;
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast);
}
.af-day:hover { background: var(--color-surface-sunken); }
.af-day.is-other { color: var(--color-text-disabled); }
.af-day.is-today { font-weight: var(--weight-bold); }
.af-day.is-today::after {
    content: '';
    position: absolute; left: 50%; bottom: 5px;
    width: 4px; height: 4px;
    margin-left: -2px;
    border-radius: 50%;
    background: var(--color-primary);
}
.af-day.is-in { border-radius: 0; background: var(--color-primary-subtle); color: var(--color-primary-text); }
.af-day.is-start, .af-day.is-end { background: var(--color-primary); color: var(--color-on-primary); font-weight: var(--weight-semibold); }
.af-day.is-start:not(.is-end) { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.af-day.is-end:not(.is-start) { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.af-day.is-start::after, .af-day.is-end::after { background: var(--color-on-primary); }
.af-day:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; z-index: 1; }

.af-cal__foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid var(--color-border);
}
.af-cal__range { font-size: var(--text-sm); color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }

/* Calendario en hoja inferior: rangos como fila deslizable */
.af-menu.is-sheet .af-dates { flex-direction: column; }
.af-menu.is-sheet .af-dates__presets {
    flex-direction: row;
    width: auto;
    gap: 6px;
    padding: 4px 12px 10px;
    border-right: 0;
    background: transparent;
    overflow-x: auto;
    scrollbar-width: none;
}
.af-menu.is-sheet .af-preset {
    width: auto;
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
}
.af-menu.is-sheet .af-preset[aria-pressed="true"] { border-color: var(--color-primary); box-shadow: none; background: var(--color-surface-selected); }
.af-menu.is-sheet .af-day { height: 44px; font-size: var(--text-base); }


/* ── 4. Búsqueda ───────────────────────────────────────────────── */
.af-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    height: 54px;
    padding: 0 10px 0 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--motion-base) var(--ease-out), box-shadow var(--motion-base) var(--ease-out);
}
.af-search:hover { border-color: var(--color-border-input); }
.af-search:focus-within { border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.af-search.has-value { border-color: var(--color-primary-border); }

.af-search__icon { display: grid; place-items: center; width: 18px; flex-shrink: 0; color: var(--color-text-muted); font-size: 18px; }
.af-search:focus-within .af-search__icon { color: var(--color-primary-text); }
.af-search.is-searching .af-search__icon iconify-icon { display: none; }
.af-search.is-searching .af-spinner { display: block; }

.af-search .af-search__input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    box-shadow: none;
    color: var(--color-text-primary);
    font: inherit;
    font-size: var(--text-base);
}
.af-search .af-search__input::placeholder { color: var(--color-text-muted); opacity: 1; }
.af-search .af-search__input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

.af-search__clear {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    flex-shrink: 0;
    padding: 0; border: 0; border-radius: 50%;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 18px;
    cursor: pointer;
    animation: afFadeIn var(--motion-base) var(--ease-out);
}
.af-search__clear:hover { color: var(--color-text-primary); background: var(--color-surface-sunken); }
.af-search__clear:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.af-search__clear[hidden] { display: none; }

.af-search__kbd {
    display: inline-flex; gap: 3px;
    flex-shrink: 0;
    padding: 0; background: none; border: 0; box-shadow: none;
    transition: opacity var(--motion-fast);
}
.af-search__kbd span {
    min-width: 22px; height: 22px;
    display: grid; place-items: center;
    padding: 0 6px;
    border: 1px solid var(--color-border);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: var(--weight-semibold);
    line-height: 1;
}
.af-search.has-value .af-search__kbd,
.af-search:focus-within .af-search__kbd { display: none; }
@media (hover: none) { .af-search__kbd { display: none; } }


/* ── 5. Barra de filtros ───────────────────────────────────────── */
.af-filters {
    container-type: inline-size;
    padding: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}
.af-filters__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.af-filters__heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.af-filters__icon {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: var(--radius-md);
    background: var(--color-primary-subtle);
    color: var(--color-primary-text);
    font-size: 18px;
}
.af-filters__title { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); color: var(--color-text-primary); line-height: 1.25; }
.af-filters__sub { margin: 0; font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.3; }
.af-filters__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.af-filters__actions [hidden] { display: none !important; }
.af-filters [data-af-clear] { animation: afFadeIn var(--motion-base) var(--ease-out); }
.af-filters__toggle { display: none !important; }

.af-count {
    min-width: 20px; height: 20px;
    display: inline-grid; place-items: center;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-size: 11px;
    font-weight: var(--weight-bold);
    line-height: 1;
}
.af-count[hidden] { display: none; }

.af-filters__grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@container (min-width: 380px) {
    .af-filters__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (min-width: 820px) {
    .af-filters__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .af-filters__grid .af-span-2 { grid-column: span 2; }
}
/* Dos columnas estrechas: el texto manda, el icono decorativo se oculta */
@container (min-width: 380px) and (max-width: 560px) {
    .af-filters__grid .af-trigger__lead:not(:has(.af-avatar, .af-dot)) { display: none; }
    .af-filters__grid .af-search__kbd { display: none; }
}

/* En escritorio la hoja es transparente: sus campos forman parte de la rejilla */
.af-sheet { display: contents; }
.af-sheet__head, .af-sheet__foot, .af-sheet-backdrop { display: none; }

/* Chips de filtros activos */
.af-filters__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.af-filters__chips[hidden] { display: none; }
.af-chip {
    display: inline-flex; align-items: center; gap: 5px;
    max-width: 100%;
    height: 30px;
    padding: 0 6px 0 12px;
    border: 1px solid var(--color-primary-border);
    border-radius: var(--radius-pill);
    background: var(--color-primary-subtle);
    color: var(--color-primary-text);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    animation: afChipIn var(--motion-base) var(--ease-out);
    transition: background-color var(--motion-fast), border-color var(--motion-fast);
}
.af-chip:hover { border-color: var(--color-primary); }
.af-chip:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.af-chip__k { color: var(--color-text-secondary); font-weight: var(--weight-medium); }
.af-chip__sep { color: var(--color-text-muted); }
.af-chip__v { font-weight: var(--weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.af-chip__x { font-size: 16px; opacity: .65; transition: opacity var(--motion-fast); }
.af-chip:hover .af-chip__x { opacity: 1; }

/* Aviso al limpiar */
.af-filters.is-cleared .af-trigger,
.af-filters.is-cleared .af-search { animation: afFlash 520ms var(--ease-out); }

/* Móvil: «Filtros (n)» + hoja inferior */
@media (max-width: 575.98px) {
    .af-filters { padding: 14px; }
    .af-filters__head { margin-bottom: 12px; }
    .af-filters__sub { display: none; }
    .af-filters__actions [data-af-clear] { display: none !important; }
    .af-filters__toggle { display: inline-flex !important; }
    .af-filters__toggle.is-active { border-color: var(--color-primary-border); color: var(--color-primary-text); }
    .af-filters__grid { grid-template-columns: 1fr; }

    .af-sheet-backdrop {
        display: block;
        position: fixed; inset: 0;
        z-index: 1079;
        background: var(--color-overlay);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--motion-slow) var(--ease-out);
    }
    .af-sheet-backdrop.is-visible { opacity: 1; pointer-events: auto; }

    .af-sheet {
        display: flex;
        flex-direction: column;
        gap: 10px;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 1080;
        max-height: 88vh;
        padding: 0 16px calc(16px + env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--color-surface-raised);
        border-radius: 22px 22px 0 0;
        box-shadow: var(--shadow-lg);
        outline: none;
        transform: translateY(100%);
        visibility: hidden;
        transition: transform var(--motion-slow) var(--ease-out), visibility 0s linear var(--motion-slow);
    }
    .af-sheet.is-open { transform: translateY(0); visibility: visible; transition: transform var(--motion-slow) var(--ease-out); }

    .af-sheet__head {
        display: block;
        position: sticky; top: 0; z-index: 1;
        margin: 0 -16px;
        padding: 8px 16px 6px;
        background: var(--color-surface-raised);
        touch-action: none;
        cursor: grab;
    }
    .af-sheet__head .af-menu__grab { margin: 0 auto 8px; }
    .af-sheet__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
    .af-sheet__title { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); color: var(--color-text-primary); }

    .af-sheet__foot {
        display: flex; gap: 8px;
        position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom));
        margin: 6px -16px calc(-16px - env(safe-area-inset-bottom));
        padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
        background: var(--color-surface-raised);
        border-top: 1px solid var(--color-border);
    }
    .af-sheet__foot .btn { flex: 1; }
    .af-sheet .af-trigger { min-height: 58px; }
}


/* ── 6. Skeleton y animaciones ─────────────────────────────────── */
.af-skel {
    display: block;
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--color-surface-sunken) 0%, var(--color-border) 50%, var(--color-surface-sunken) 100%);
    background-size: 200% 100%;
    animation: afShimmer 1.3s ease-in-out infinite;
}
.af-skel--circle { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.af-skel--block { width: 42px; height: 42px; border-radius: var(--radius-md); flex-shrink: 0; }
.af-skel-row {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
.af-skel-row__text { flex: 1; display: flex; flex-direction: column; gap: 8px; }

@keyframes afSpin { to { transform: rotate(360deg); } }
@keyframes afShimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes afFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes afPop { 0% { transform: scale(.86); } 60% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes afDotIn { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes afChipIn { from { opacity: 0; transform: translateY(3px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes afFlash { 0% { background-color: var(--color-primary-subtle); } 100% { background-color: var(--color-surface); } }

@media (forced-colors: active) {
    .af-dot { forced-color-adjust: none; }
    .af-opt[aria-selected="true"], .af-day.is-start, .af-day.is-end { outline: 2px solid Highlight; }
}
