/* Glassmorphism & Premium UI for Optometry Tools */

/* Hand attached to Bag */
.bag-hand {
    position: absolute;
    top: -18px;
    /* On handle */
    left: -12px;
    width: 30px;
    height: 30px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: scale(0) rotate(-15deg);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    color: #6366f1;
    pointer-events: none;
    border: 1.5px solid rgba(99, 102, 241, 0.3);
}

.bag-hand span {
    font-size: 18px;
    font-weight: bold;
}

#fab-optometria.is-carried.is-moving .bag-hand {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Conector Tecnológico (Desde atrás) */
.tether-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    /* Dinámico por JS */
    height: 2px;
    background: linear-gradient(to right, rgba(99, 102, 241, 0.8), rgba(129, 140, 248, 0.9), rgba(99, 102, 241, 0.8));
    transform-origin: left center;
    z-index: 1;
    /* Detrás del avatar que tiene 100 */
    opacity: 0;
    pointer-events: none;
    filter: blur(0.5px);
    transition: opacity 0.2s ease;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.7), 0 0 12px rgba(129, 140, 248, 0.4);
    will-change: width, transform, opacity;
}

.opti-mentor-wrapper.dragging .tether-line,
.dragging-bag .tether-line {
    opacity: 0.75;
    height: 2.5px;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.9), 0 0 16px rgba(129, 140, 248, 0.5);
}

@keyframes handGrip {
    from {
        transform: scale(1) rotate(-5deg);
    }

    to {
        transform: scale(0.9) rotate(5deg);
    }
}

#fab-optometria.is-carried {
    transition: none !important;
    animation: none !important;
    box-shadow: 0 30px 60px rgba(99, 102, 241, 0.7) !important;
    z-index: 9999;
    /* Por encima del asistente durante el arrastre */
    filter: brightness(1.1) saturate(1.2);
    position: fixed !important;
    /* Asegurar que se puede mover libremente */
    transform-origin: center center;
    will-change: transform, left, top;
}

#fab-optometria.is-carried.is-moving .bag-hand {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

#fab-optometria.is-carried::before {
    top: -14px !important;
    height: 16px !important;
    border-color: #ffffff !important;
    border-width: 4px !important;
}

:root {
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

/* FAB Button */
/* FAB Button - Doctor's Bag Style (AI Assistant Accessory) */
#fab-optometria {
    position: fixed;
    bottom: 95px;
    /* Satellite position above AI Assistant */
    right: 25px;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    /* Squircle for "Bag" shape */
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    /* AI Assistant Theme */
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    z-index: 9998;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: bagFloat 3s ease-in-out infinite;
}

#fab-optometria::before {
    /* Handle visual hint - Visible now */
    content: '';
    position: absolute;
    top: -8px;
    width: 24px;
    height: 10px;
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    background: transparent;
    transition: all 0.3s ease;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

/* Tooltip on Hover */
#fab-optometria::after {
    content: 'Herramientas';
    position: absolute;
    right: 65px;
    background: #0f172a;
    color: white;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px) scale(0.9);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    visibility: hidden;
}

#fab-optometria:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
}

#fab-optometria:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.5), 0 0 0 4px rgba(99, 102, 241, 0.2);
    /* Glow ring */
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

#fab-optometria:hover::before {
    top: -10px;
    /* Handle lifts slightly */
    height: 12px;
    border-color: #ffffff;
}

@keyframes bagFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* Modal Overlay */
#modal-optometria-tools {
    /* removed backdrop-filter */
    background: transparent;
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    pointer-events: none;
}

#modal-optometria-tools.active {
    opacity: 1;
    pointer-events: none;
    /* No bloquea clics en el fondo */
}




/* Modal Container */
.premium-modal {
    background: var(--glass-bg);
    width: 480px;
    max-width: 92vw;
    height: 70vh;
    max-height: 90vh;
    min-width: 260px;
    min-height: 300px;
    border-radius: 24px;
    border: var(--glass-border);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    /* IMPORTANTE: El modal sí es interactivo */
    resize: both;
}


.premium-modal-morph-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;

    /* Nueva animación de maletica */
    transform: scale(0.05);
    /* Comienza más pequeño */
    opacity: 0;
    filter: blur(8px);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform, opacity, filter;
    transform-origin: center center;
}

#modal-optometria-tools.active .premium-modal-morph-wrap {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
}


.premium-modal-morph-wrap.is-closing {
    transform: scale(0.05) !important;
    opacity: 0 !important;
    filter: blur(12px) !important;
    transition: all 0.7s cubic-bezier(0.4, 0, 1, 1) !important;
}




@media (max-width: 340px),
(max-height: 520px) {
    .premium-modal {
        width: 96vw;
        height: 92vh;
        min-width: 0;
        min-height: 0;
        border-radius: 18px;
    }

    .premium-header {
        padding: 10px 14px;
    }

    .premium-tabs {
        padding: 6px 10px;
        gap: 6px;
    }

    .premium-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .premium-content {
        padding: 12px;
    }
}

/* Header */
.premium-header {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.premium-header:active {
    cursor: grabbing;
}

.premium-title {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tabs */
.premium-tabs {
    display: flex;
    overflow-x: auto;
    padding: 8px 16px;
    gap: 8px;
    background: #f8fafc;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
    flex: 0 0 auto;
}

.premium-tabs::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar Chrome */

.premium-tab {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid transparent;
    background: transparent;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.premium-tab.active {
    background: white;
    color: #4f46e5;
    border-color: #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Content Area */
.premium-content {
    padding: clamp(14px, 2.5vw, 24px);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
}

#modal-optometria-tools[data-active-tool="calculadora"] .premium-content {
    overflow: hidden;
}

#modal-optometria-tools .tool-content {
    height: 100%;
}

#modal-optometria-tools #tool-calculadora {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#modal-optometria-tools #calc-scale-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    transform-origin: top left;
    will-change: transform;
}

#modal-optometria-tools #calc-display {
    padding: clamp(12px, 2.5vw, 20px) !important;
    font-size: clamp(1.2rem, 3vw, 2rem) !important;
    margin-bottom: clamp(10px, 1.8vw, 15px) !important;
}

/* Results Display Animation */
.result-box {
    animation: fadeIn 0.5s ease-out;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
    text-align: center;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #2563eb;
    margin-top: 4px;
    text-shadow: 0 1px 2px rgba(37, 99, 235, 0.1);
}

/* Calculator Grid */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(8px, 1.6vw, 10px);
    flex: 1 1 auto;
    min-height: 0;
}

.calc-btn {
    padding: clamp(10px, 2.2vw, 16px);
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    cursor: pointer;
    transition: transform 0.1s;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    color: #334155;
    min-width: 0;
}

.calc-btn:active {
    transform: scale(0.95);
}

.calc-btn.op {
    background: #f1f5f9;
    color: #475569;
}

.calc-btn.action {
    background: #fee2e2;
    color: #ef4444;
}

.calc-btn.equal {
    background: var(--primary-gradient);
    color: white;
}

/* Animations */
@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =========================================
   VISUAL CALENDAR / TIME SLOTS
   ========================================= */
.time-slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
}

.time-slot-btn {
    padding: 8px 4px;
    border: 1px solid #bfdbfe;
    background: #f0f9ff;
    color: #0369a1;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.time-slot-btn:hover:not(:disabled) {
    background: #e0f2fe;
    border-color: #3b82f6;
    transform: translateY(-1px);
}

.time-slot-btn.selected {
    background: #0f172a;
    /* Medical Dark Blue */
    color: white;
    border-color: #0f172a;
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.2);
}

.time-slot-btn:disabled,
.time-slot-btn.occupied {
    background: #f1f5f9;
    color: #cbd5e1;
    border-color: #e2e8f0;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* =========================================
   APPLE CALENDAR MODAL
   ========================================= */

.cal-apple-modal {
    max-width: 1040px !important;
    max-height: min(92vh, 860px);
    padding: 0 !important;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-radius: 32px !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 252, 0.96)) !important;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 40px 80px rgba(15, 23, 42, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.75) !important;
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
}

.cal-apple-shell {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: inherit;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
}

.cal-apple-shell::-webkit-scrollbar {
    width: 10px;
}

.cal-apple-shell::-webkit-scrollbar-track {
    background: transparent;
}

.cal-apple-shell::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.38);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.cal-apple-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cal-apple-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cal-apple-icon-wrap {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: linear-gradient(135deg, #0a84ff, #5e5ce6);
    box-shadow: 0 16px 30px rgba(10, 132, 255, 0.28);
}

.cal-apple-icon-wrap .material-symbols-outlined {
    font-size: 1.55rem;
}

.cal-apple-title {
    margin: 0;
    color: #0f172a;
    font-size: 1.28rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.cal-apple-subtitle {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 600;
}

.cal-apple-close {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(241, 245, 249, 0.9);
    color: #334155;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.cal-apple-toolbar {
    display: grid;
    grid-template-columns: 52px 1fr 52px;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.cal-nav-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.92));
    color: #0f172a;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease, background 0.28s ease;
}

.cal-nav-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.cal-nav-btn .material-symbols-outlined {
    font-size: 1.35rem;
}

.cal-apple-month {
    margin: 0;
    text-align: center;
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-transform: capitalize;
}

.cal-apple-weekdays,
.cal-apple-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.cal-apple-body {
    display: block;
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 1;
    align-items: start;
    overflow: visible;
}

.cal-apple-main {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    align-self: start;
}

.cal-apple-weekday {
    text-align: center;
    padding: 8px 6px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.cal-apple-grid {
    grid-auto-rows: auto;
    align-items: start;
}

.cal-empty-cell {
    min-height: 78px;
    height: auto;
    aspect-ratio: 1 / 1;
}

.cal-day-cell {
    position: relative;
    min-height: 78px;
    height: auto;
    aspect-ratio: 1 / 1;
    padding: 10px 10px 8px;
    border-radius: 22px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.95));
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.88);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease, border-color 0.28s ease, background 0.28s ease;
}

.cal-day-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.cal-day-cell.is-today {
    border-color: rgba(10, 132, 255, 0.5);
    background: linear-gradient(180deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.98));
}

.cal-day-cell.is-selected {
    border-color: rgba(94, 92, 230, 0.45);
    box-shadow: 0 0 0 3px rgba(94, 92, 230, 0.12), 0 18px 34px rgba(15, 23, 42, 0.12);
}

.cal-day-cell.has-items .cal-day-number {
    color: #0f172a;
}

.cal-day-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cal-day-number {
    font-size: 1rem;
    font-weight: 900;
    color: #475569;
}

.cal-day-badge {
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.74rem;
    font-weight: 800;
    color: #0a84ff;
    background: rgba(10, 132, 255, 0.1);
}

.cal-day-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.cal-day-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55);
}

.cal-day-preview {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 0;
}

.cal-day-preview-chip {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(241, 245, 249, 0.92);
    color: #475569;
    font-size: 0.66rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-day-preview-more {
    color: #94a3b8;
    font-size: 0.66rem;
    font-weight: 700;
}

/* Modal Flotante de Citas (Nueva Ventana al hacer click) */
.cal-apple-detail-panel {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) scale(0.9) !important;
    width: min(92%, 620px) !important;
    min-width: min(92%, 420px);
    max-width: 620px !important;
    height: auto !important;
    max-height: min(78vh, 640px) !important;
    z-index: 10002 !important;
    /* Aumentado por encima de cualquier otra capa interna */
    display: none;
    flex-direction: column;
    gap: 16px;
    padding: 24px !important;
    border-radius: 28px !important;
    border: 2px solid rgba(0, 0, 0, 0.1) !important;
    background: #ffffff !important;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3) !important;
    opacity: 0;
    transition: all 0.25s ease-out;
    pointer-events: auto !important;
    /* ASEGURAR INTERACCIÓN */
    overflow: hidden;
}

.cal-apple-detail-panel.is-active {
    display: flex !important;
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

/* Overlay sutil para la ventana de citas */
.cal-detail-overlay {
    display: none !important;
    pointer-events: none !important;
}

.cal-detail-overlay.is-active {
    display: none !important;
}

.cal-apple-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.cal-apple-detail-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
}

.cal-apple-detail-list {
    display: grid;
    gap: 10px;
    flex: 1 1 auto;
    max-height: min(62vh, 520px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    padding-right: 4px;
}

.cal-apple-detail-list::-webkit-scrollbar,
.cal-apple-modal::-webkit-scrollbar {
    width: 10px;
}

.cal-apple-detail-list::-webkit-scrollbar-track,
.cal-apple-modal::-webkit-scrollbar-track {
    background: transparent;
}

.cal-apple-detail-list::-webkit-scrollbar-thumb,
.cal-apple-modal::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.38);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.cal-detail-empty {
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.98));
    border: 1px dashed #dbe4f0;
    color: #64748b;
    font-weight: 700;
    text-align: center;
}

.cal-detail-section-label {
    margin: 10px 0 2px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.cal-detail-card {
    display: grid;
    grid-template-columns: minmax(104px, 118px) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.95));
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.cal-detail-card-time {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 800;
    color: #2563eb;
}

.cal-detail-card-time .material-symbols-outlined {
    font-size: 1rem;
}

.cal-detail-card-title {
    font-size: 0.96rem;
    font-weight: 800;
    color: #0f172a;
}

.cal-detail-card-subtitle,
.cal-detail-card-meta {
    margin-top: 4px;
    font-size: 0.8rem;
    color: #64748b;
}

.cal-detail-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-self: center;
}

.cal-detail-state-select {
    padding: 8px 12px !important;
    border-radius: 12px !important;
    font-size: 0.76rem !important;
    font-weight: 800 !important;
    min-width: 124px;
}

.cal-detail-add-btn {
    border: none;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0a84ff, #5e5ce6);
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(10, 132, 255, 0.18);
}

.cal-detail-action-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 12px;
    background: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    cursor: pointer;
}

.cal-detail-action-btn .material-symbols-outlined {
    font-size: 1rem;
}

.cal-detail-action-btn.is-danger {
    color: #dc2626;
    background: #fff5f5;
    border-color: rgba(248, 113, 113, 0.22);
}

@media (max-width: 1120px) {
    .cal-apple-modal {
        width: min(96vw, 920px) !important;
    }

    .cal-apple-body {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .cal-apple-main {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        margin-bottom: 24px;
        border-right: none !important;
    }

    .cal-apple-detail-panel {
        width: min(94vw, 560px) !important;
        min-width: 0;
        max-height: min(76vh, 620px) !important;
        border-radius: 24px;
    }

    .cal-apple-detail-list {
        max-height: min(60vh, 500px) !important;
        overflow-y: auto !important;
    }

    .cal-detail-card {
        grid-template-columns: minmax(92px, 110px) minmax(0, 1fr);
        align-items: flex-start;
    }

    .cal-detail-card-actions {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .cal-apple-shell {
        padding: 16px;
        min-height: auto;
    }

    .cal-apple-header,
    .cal-apple-title-group {
        align-items: flex-start;
    }

    .cal-apple-header {
        flex-direction: column;
    }

    .cal-apple-title-group {
        width: 100%;
    }

    .cal-apple-close {
        align-self: flex-end;
    }

    .cal-apple-toolbar {
        grid-template-columns: 44px 1fr 44px;
        gap: 10px;
        padding: 8px 10px;
        border-radius: 18px;
    }

    .cal-nav-btn {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }

    .cal-apple-body {
        height: auto;
        overflow: visible;
    }

    .cal-apple-main {
        overflow: visible;
    }

    .cal-apple-detail-panel {
        width: calc(100% - 18px) !important;
        min-width: 0;
        max-width: 100% !important;
        max-height: min(78vh, 560px) !important;
        padding: 16px !important;
        border-radius: 22px !important;
    }

    .cal-apple-weekdays,
    .cal-apple-grid {
        gap: 6px;
    }

    .cal-apple-weekday {
        font-size: 0.63rem;
        padding: 4px 2px;
        letter-spacing: 0.04em;
    }

    .cal-day-cell,
    .cal-empty-cell {
        min-height: 72px;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .cal-day-cell {
        padding: 8px 6px;
        border-radius: 16px;
    }

    .cal-day-top {
        gap: 4px;
    }

    .cal-day-number {
        font-size: 0.92rem;
    }

    .cal-day-badge {
        min-width: 20px;
        height: 20px;
        padding: 0 5px;
        font-size: 0.62rem;
    }

    .cal-day-dots {
        gap: 4px;
    }

    .cal-day-dot {
        width: 6px;
        height: 6px;
    }

    .cal-day-preview {
        gap: 2px;
    }

    .cal-day-preview-chip,
    .cal-day-preview-more {
        font-size: 0.58rem;
    }

    .cal-day-preview-chip {
        max-width: 100%;
        padding: 2px 6px;
    }

    .cal-detail-card {
        grid-template-columns: 1fr;
        align-items: flex-start;
        padding: 12px;
        border-radius: 18px;
    }

    .cal-detail-card-time {
        font-size: 0.84rem;
    }

    .cal-detail-card-title {
        font-size: 0.9rem;
    }

    .cal-detail-card-subtitle,
    .cal-detail-card-meta {
        font-size: 0.76rem;
    }

    .cal-detail-card-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .cal-apple-detail-panel {
        max-height: min(78vh, 560px) !important;
        height: auto;
        padding: 14px;
    }

    .cal-detail-state-select {
        width: 100%;
        min-width: 0;
    }

    .cal-detail-add-btn {
        width: 100%;
        justify-content: center;
    }

    #view-citas {
        overflow-x: hidden;
    }

    .citas-main-layout {
        gap: 12px;
    }

    .citas-list-panel {
        height: auto;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .citas-form-row-schedule {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .citas-form-schedule-date,
    .citas-form-schedule-slots,
    .citas-form-schedule-action {
        width: 100%;
        min-width: 0 !important;
    }

    .citas-form-date-head {
        gap: 8px;
        flex-wrap: wrap;
    }

    .citas-form-schedule-action {
        padding-bottom: 0 !important;
    }

    .citas-btn-confirmar {
        width: 100%;
        justify-content: center;
    }

    #cita-visual-slots {
        max-height: 180px !important;
    }

    .citas-header-actions .citas-header-btn-primary {
        width: 100%;
    }

    .citas-list-header {
        align-items: flex-start;
        gap: 8px;
    }

    .cita-card {
        padding: 14px !important;
    }

    .cita-card-name {
        font-size: 0.96rem;
    }

    .cita-card-meta-item {
        width: 100%;
        justify-content: flex-start;
    }

    .cita-card-action {
        flex: 1 1 44px;
    }
}

/* =========================================
   CITAS UX – Apple Natural / Organic
   ========================================= */

@keyframes citasFadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes citasFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.citas-header {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.93) 0%, rgba(0, 78, 156, 0.96) 100%);
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
    border-radius: 16px;
    padding: 14px 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 60, 140, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: box-shadow 0.6s ease;
}

.citas-header:hover {
    box-shadow: 0 6px 28px rgba(0, 60, 140, 0.2);
}

.citas-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.citas-title-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.citas-title-icon {
    font-size: 1.45rem !important;
    color: white;
}

.citas-title-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.citas-title-main {
    margin: 0;
    color: white;
    font-size: 1.16rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.citas-title-sub {
    margin: 0;
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.78rem;
    font-weight: 500;
}

.citas-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.citas-stats-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.citas-header-divider {
    width: 1px;
    height: 26px;
    background: rgba(255, 255, 255, 0.28);
}

.citas-stat-badge {
    color: white;
    padding: 5px 14px;
    border-radius: 24px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
    border: 1px solid rgba(255, 255, 255, 0.12);
    animation: citasFadeIn 0.5s ease both;
    transition: background 0.4s ease;
    cursor: default;
}

.citas-stat-badge:nth-child(2) {
    animation-delay: 0.04s;
}

.citas-stat-badge:nth-child(3) {
    animation-delay: 0.08s;
}

.citas-stat-badge:nth-child(4) {
    animation-delay: 0.12s;
}

.citas-stat-badge:nth-child(5) {
    animation-delay: 0.16s;
}

.citas-stat-badge:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}

.citas-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    padding: 7px 14px;
    font-weight: 600;
    border-radius: 10px;
    font-size: 0.84rem;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.25s ease, box-shadow 0.4s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.citas-header-btn:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.citas-header-btn:active {
    opacity: 0.7;
    transition: opacity 0.1s ease;
}

.citas-header-btn .material-symbols-outlined {
    font-size: 1.1rem;
}

.citas-header-btn-primary {
    background: rgba(255, 255, 255, 0.96);
    color: #0f5fbe;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 16px;
    font-size: 0.98rem;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.citas-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.75);
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(226, 232, 240, 0.5);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.5s ease;
}

.citas-toolbar:hover {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
}

.citas-toolbar-shell {
    justify-content: flex-start;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.citas-toolbar-left {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(240px, 2fr) minmax(150px, 1fr) minmax(170px, 1.1fr) minmax(140px, 1fr);
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.citas-toolbar-right {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-shrink: 0;
}

.citas-toolbar-cta-wrap {
    align-self: stretch;
}

.citas-filter-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 0 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(203, 213, 225, 0.62);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transition: border-color 0.38s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.38s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease, transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.citas-filter-wrap:focus-within {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.12);
    background: white;
    transform: translateY(-1px);
}

.citas-filter-icon {
    color: #94a3b8;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.citas-filter-input {
    padding: 9px 14px;
    border: 1px solid rgba(203, 213, 225, 0.6);
    border-radius: 10px;
    font-size: 0.86rem;
    min-width: 0;
    background: rgba(255, 255, 255, 0.85);
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
    transition: border-color 0.38s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.38s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease, transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    outline: none;
}

.citas-filter-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: white;
    transform: translateY(-1px);
}

.citas-filter-input-search {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 14px 0;
    font-size: 0.98rem;
    width: 100%;
}

.citas-filter-input-search:focus {
    box-shadow: none;
    border-color: transparent;
    background: transparent;
}

.citas-filter-select,
.citas-filter-date {
    min-height: 54px;
    border-radius: 18px;
    font-size: 0.98rem;
    padding: 0 18px;
    color: #1e293b;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.citas-filter-select:hover,
.citas-filter-date:hover,
.citas-filter-wrap:hover {
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.citas-btn-agendar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.42s cubic-bezier(0.22, 1.18, 0.36, 1), box-shadow 0.42s cubic-bezier(0.22, 1.18, 0.36, 1), opacity 0.2s ease, filter 0.35s ease;
    box-shadow: 0 3px 12px rgba(79, 70, 229, 0.25);
    will-change: transform;
}

.citas-btn-agendar:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(79, 70, 229, 0.28);
    filter: saturate(1.08);
}

.citas-btn-agendar:active {
    transform: translateY(0) scale(0.97);
    opacity: 0.92;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.citas-btn-agendar-xl {
    min-width: 236px;
    min-height: 58px;
    justify-content: center;
    padding: 0 28px 0 22px;
    border-radius: 20px;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #5b4ff6 0%, #4338ca 58%, #3b82f6 100%);
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.citas-btn-agendar-xl:hover {
    box-shadow: 0 18px 38px rgba(79, 70, 229, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.citas-btn-agendar-xl::before {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
    pointer-events: none;
}

.citas-btn-agendar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
    font-size: 1.25rem;
    transition: transform 0.42s cubic-bezier(0.22, 1.18, 0.36, 1), background 0.35s ease;
}

.citas-btn-agendar:hover .citas-btn-agendar-icon {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.24);
}

.citas-main-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.citas-form-panel {
    animation: citasFadeUp 0.4s ease both;
}

.citas-form-card {
    background: rgba(255, 255, 255, 0.88);
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
    padding: 20px 24px;
    border-left: 4px solid #6366f1;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(226, 232, 240, 0.4);
    transition: box-shadow 0.5s ease;
}

.citas-form-card:hover {
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.citas-form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.citas-input-sm {
    padding: 9px 12px !important;
    font-size: 0.86rem !important;
    border-radius: 10px !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
}

.citas-input-sm:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08) !important;
}

.citas-btn-confirmar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 22px;
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.94rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.25);
    transition: box-shadow 0.4s ease, opacity 0.2s ease;
    white-space: nowrap;
}

.citas-btn-confirmar:hover {
    box-shadow: 0 8px 28px rgba(79, 70, 229, 0.35);
}

.citas-btn-confirmar:active {
    opacity: 0.8;
    transition: opacity 0.1s ease;
}

.citas-list-panel {
    height: auto;
    overflow-y: visible;
    padding-right: 12px;
    padding-bottom: 60px;
    scroll-behavior: smooth;
}

.citas-list-panel::-webkit-scrollbar {
    width: 6px;
}

.citas-list-panel::-webkit-scrollbar-track {
    background: transparent;
}

.citas-list-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.citas-list-panel::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.badge-sede {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.badge-sede-icon {
    font-size: 14px !important;
    color: #0ea5e9;
}

/* Countdown Styles */
.cita-countdown {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    margin-left: 8px;
}

.cita-countdown.urgent {
    background: #fee2e2;
    color: #ef4444;
    animation: pulse-countdown 1.5s infinite;
}

.cita-countdown.upcoming {
    background: #f0fdf4;
    color: #16a34a;
}

.cita-countdown.delayed {
    background: #fffbeb;
    color: #d97706;
}

@keyframes pulse-countdown {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.03); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}


.citas-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    position: sticky;
    top: 0;
    background: rgba(241, 245, 249, 0.88);
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
    z-index: 10;
    padding: 10px 4px;
    border-radius: 12px;
}

.citas-list-title {
    margin: 0;
    color: #334155;
    font-size: 1rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.citas-list-title .material-symbols-outlined {
    font-size: 1.05rem;
    color: #4f46e5;
}

.citas-list-panel .venta-card,
#lista-citas-contenedor>div {
    transition: box-shadow 0.4s ease, transform 0.35s ease;
    border-radius: 14px !important;
    overflow: visible !important;
}

.citas-list-panel .venta-card:hover,
#lista-citas-contenedor>div:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.citas-list-panel .venta-card:active,
#lista-citas-contenedor>div:active {
    transform: translateY(0);
    opacity: 0.85;
    transition: opacity 0.1s ease, transform 0.1s ease;
}

.citas-empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 34px 24px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.98));
    border-radius: 20px;
    border: 1px dashed #dbe4f0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.citas-empty-state .material-symbols-outlined {
    font-size: 2.2rem;
    margin-bottom: 10px;
    color: #a5b4fc;
}

.citas-empty-title {
    font-size: 1rem;
    font-weight: 800;
    color: #475569;
}

.citas-empty-subtitle {
    margin-top: 6px;
    font-size: 0.84rem;
}

.cita-card {
    padding: 16px 28px 16px 22px !important;
    border-radius: 18px !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.95)) !important;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    overflow: hidden !important;
    box-sizing: border-box;
    max-width: 100%;
}

.citas-list-panel .venta-card.cita-card,
#lista-citas-contenedor .venta-card.cita-card {
    overflow: visible !important;
}

.cita-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    min-width: 0;
}

.cita-card-schedule {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.cita-card-day-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.08);
    color: #4338ca;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cita-card-day-pill.is-today {
    background: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

@keyframes today-card-pulse {
    0% {
        box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.9);
        transform: scale(1.0);
    }
    50% {
        box-shadow: 0 12px 32px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.9);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.9);
        transform: scale(1.0);
    }
}

.cita-card.is-today-card {
    background: linear-gradient(180deg, rgba(255, 247, 237, 0.98), rgba(254, 243, 199, 0.96)) !important;
    animation: today-card-pulse 2.5s infinite ease-in-out;
    border-width: 2px !important;
    border-style: solid !important;
}

[data-theme="dark"] .cita-card.is-today-card {
    background: linear-gradient(180deg, rgba(69, 26, 3, 0.98), rgba(61, 25, 0, 0.96)) !important;
}

.cita-card-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.84rem;
    color: #64748b;
    font-weight: 700;
}

.cita-card-time .material-symbols-outlined {
    font-size: 1rem;
    color: #94a3b8;
}

.cita-estado-select {
    padding: 6px 12px !important;
    border-radius: 12px !important;
    font-weight: 800 !important;
    font-size: 0.78rem !important;
    min-width: 132px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.cita-card-name {
    font-size: 1.04rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
    margin-bottom: 8px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cita-card-motivo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cita-card-motivo .material-symbols-outlined {
    font-size: 1rem;
    color: #6366f1;
}

.cita-card-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-width: 0;
}

.cita-card-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 12px;
    background: rgba(241, 245, 249, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.9);
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cita-card-meta-item .material-symbols-outlined {
    font-size: 1rem;
    color: #64748b;
}

.cita-card-meta-item.is-muted {
    color: #94a3b8;
}

.cita-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    min-width: 0;
}

.cita-card-status-hint {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 0;
    overflow-wrap: anywhere;
}

.cita-card-status-hint .material-symbols-outlined {
    font-size: 1rem;
    color: #f59e0b;
}

.cita-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
    max-width: 100%;
    margin-left: auto;
}

.cita-card-action-wrap {
    position: relative;
    display: inline-flex;
    z-index: 100;
}

.cita-card-action {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    flex: 0 0 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 12px !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    background: rgba(255, 255, 255, 0.9) !important;
    color: #475569 !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, color 0.3s ease !important;
}

.cita-card-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.09);
    background: white !important;
    color: #1e293b !important;
}

.cita-card-action .material-symbols-outlined {
    font-size: 1.05rem !important;
}

.cita-card-action-wa {
    background: linear-gradient(135deg, #25D366, #1faa52) !important;
    border-color: #25D366 !important;
    box-shadow: 0 8px 18px rgba(37, 211, 102, 0.22) !important;
    color: white !important;
}

.cita-card-action-wa:hover {
    background: linear-gradient(135deg, #28df6d, #1fa84f) !important;
    color: white !important;
}

.cita-card-action-wa svg {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
}

.cita-card-action-wa .cita-card-action-wa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.cita-card-action-danger:hover {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    border-color: rgba(248, 113, 113, 0.28) !important;
}

.cita-wa-menu {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(100% + 8px);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 16px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
    overflow: hidden;
    width: 220px;
    z-index: 500;
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
}

.cita-wa-menu-btn {
    width: 100%;
    border: none;
    background: transparent;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    font-weight: 700;
    color: #0f172a;
    font-size: 0.9rem;
    transition: background 0.25s ease, color 0.25s ease;
}

.cita-wa-menu-btn:hover {
    background: #f8fafc;
    color: #4338ca;
}

.cita-wa-menu-divider {
    height: 1px;
    background: #e2e8f0;
}

@media (min-width: 1801px) {
    #view-citas .venta-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

[data-theme="dark"] .cita-card {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.96)) !important;
    border-color: rgba(51, 65, 85, 0.95) !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
}

[data-theme="dark"] .cita-card-name {
    color: #f8fafc;
}

[data-theme="dark"] .cita-card-motivo,
[data-theme="dark"] .cita-card-time,
[data-theme="dark"] .cita-card-status-hint {
    color: #cbd5e1;
}

[data-theme="dark"] .cita-card-meta-item {
    background: rgba(15, 23, 42, 0.72);
    border-color: rgba(51, 65, 85, 0.95);
    color: #cbd5e1;
}

[data-theme="dark"] .cita-card-footer {
    border-top-color: rgba(51, 65, 85, 0.9);
}

[data-theme="dark"] .cita-card-action {
    background: rgba(30, 41, 59, 0.94) !important;
    border-color: rgba(71, 85, 105, 0.95) !important;
    color: #e2e8f0 !important;
}

@media (max-width: 768px) {
    .citas-form-grid-3 {
        grid-template-columns: 1fr;
    }

    .citas-toolbar {
        flex-direction: column;
        padding: 8px 10px;
    }

    .citas-toolbar-shell {
        padding: 12px;
        border-radius: 18px;
    }

    .citas-toolbar-left {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .citas-toolbar-right {
        width: 100%;
    }

    .citas-btn-agendar-xl {
        width: 100%;
        min-width: 0;
    }

    .citas-filter-wrap,
    .citas-filter-select,
    .citas-filter-date {
        width: 100%;
    }

    .citas-stat-badge {
        font-size: 0.68rem;
        padding: 3px 8px;
    }

    .citas-header {
        padding: 12px 14px;
        border-radius: 14px;
    }

    .citas-title-group {
        width: 100%;
    }

    .citas-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .citas-stats-inline {
        width: 100%;
    }

    .citas-header-divider {
        display: none;
    }

    .citas-form-card {
        padding: 14px 16px;
    }

    .cita-card-top,
    .cita-card-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .cita-estado-select {
        width: 100%;
    }

    .cita-card-actions {
        width: 100%;
    }

    .cita-card-action-wrap {
        position: relative;
    }

    .cita-wa-menu {
        left: 0;
        right: auto;
        transform: none;
        width: min(220px, calc(100vw - 48px));
    }
}

@media (max-width: 1180px) {
    .citas-toolbar-left {
        grid-template-columns: minmax(220px, 1.8fr) minmax(140px, 1fr);
    }

    .citas-toolbar-shell {
        flex-direction: column;
        align-items: stretch;
    }

    .citas-toolbar-cta-wrap {
        width: 100%;
    }

    .citas-filter-date {
        grid-column: span 1;
    }
}

/* === VIEW TOGGLE (GRID / LIST) === */
.pac-view-toggle {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 3px;
    gap: 2px;
    border: 1px solid #e2e8f0;
    height: 42px;
    align-items: center;
}

.pac-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 34px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.pac-view-btn:hover {
    color: #475569;
    background: rgba(255, 255, 255, 0.5);
}

.pac-view-btn.active {
    background: white;
    color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15), 0 1px 3px rgba(0, 0, 0, 0.06);
}

.pac-view-btn .material-symbols-outlined {
    font-size: 20px;
}

/* === PATIENT GRID (DEFAULT) === */
.patient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
    align-items: start;
    animation: fadeInGrid 0.4s ease-out;
}

@keyframes fadeInGrid {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ======================================
   LIST VIEW MODE
   ====================================== */
.patient-grid.list-view {
    grid-template-columns: 1fr;
    gap: 8px;
}

.patient-grid.list-view .patient-card {
    border-radius: 14px;
    border-width: 1px;
    padding: 0;
    height: auto;
    min-height: 0;
}

.patient-grid.list-view .patient-card-front-shell {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.patient-grid.list-view .patient-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.patient-grid.list-view .patient-header {
    flex-shrink: 0;
    border-bottom: none;
    padding: 12px 16px;
    min-width: 0;
    width: 100%;
    background: transparent;
    gap: 10px;
}

.patient-grid.list-view .patient-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1rem;
}

.patient-grid.list-view .patient-name {
    font-size: 0.9rem;
    max-width: 260px;
}

.patient-grid.list-view .patient-id {
    font-size: 0.68rem;
    padding: 2px 6px;
}

.patient-grid.list-view .patient-body {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(220px, 1.15fr) minmax(180px, 0.95fr) minmax(250px, 1.05fr);
    align-items: center;
    padding: 8px 12px;
    gap: 16px;
    min-width: 0;
    overflow: hidden;
}

.patient-grid.list-view .patient-contact {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
    min-width: 0;
    flex-wrap: wrap;
}

.patient-grid.list-view .patient-contact-item {
    padding: 6px 10px;
    font-size: 0.8rem;
    border: none;
    background: transparent;
    gap: 6px;
    min-width: 0;
}

.patient-grid.list-view .patient-contact-item:hover {
    transform: none;
    background: #f1f5f9;
    border-radius: 8px;
}

.patient-grid.list-view .patient-clinical {
    display: grid;
    grid-template-columns: repeat(3, minmax(74px, 1fr));
    gap: 8px;
    margin-top: 0;
    flex-shrink: 0;
    min-width: 0;
}

.patient-grid.list-view .patient-clinical.has-status {
    grid-template-columns: repeat(3, minmax(74px, 1fr));
}

.patient-grid.list-view .clinical-stat {
    padding: 6px 10px;
    border-radius: 8px;
    border-width: 1px;
    min-width: 70px;
}

.patient-grid.list-view .patient-note-card {
    min-width: 0;
    min-height: 54px;
    padding: 7px 10px;
}

.patient-grid.list-view .patient-note-label {
    margin-bottom: 2px;
}

.patient-grid.list-view .patient-note-text {
    -webkit-line-clamp: 1;
    min-height: 1.28em;
}

.patient-grid.list-view .clinical-label {
    font-size: 0.6rem;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

.patient-grid.list-view .clinical-val {
    font-size: 0.78rem;
}

.patient-grid.list-view .visit-status-indicator {
    font-size: 0.65rem;
    padding: 4px 8px;
}

.patient-grid.list-view .profile-completeness {
    display: none;
}

.patient-grid.list-view .patient-footer {
    flex-shrink: 0;
    border-top: none;
    border-left: 1px solid #f1f5f9;
    padding: 8px 14px;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

/* Elevar z-index de la tarjeta con dropdown activo */
.patient-grid.list-view .patient-card:has(.hc-dropdown.active) {
    z-index: 1000 !important;
    position: relative;
    overflow: visible !important;
}

.patient-grid.list-view .patient-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: visible !important;
}

.patient-grid.list-view .hc-dropdown-trigger {
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: none;
    background: #6366f1;
}

/* Fix dropdown en modo lista: abrir hacia abajo, alineado a la derecha del botón */
.patient-grid.list-view .hc-dropdown {
    position: relative;
}

.patient-grid.list-view .hc-dropdown-content {
    position: absolute;
    top: 105%;
    /* Justo debajo del botón */
    bottom: auto;
    left: auto;
    right: 0;
    /* Alineado al borde derecho del botón */
    min-width: 220px;
    z-index: 10000;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    animation: hcDropList 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes hcDropList {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.patient-grid.list-view .hc-dropdown-content a {
    padding: 10px 14px;
    font-size: 0.82rem;
    gap: 8px;
}

/* Asegurar que el card no corta el dropdown */
.patient-grid.list-view .patient-card {
    overflow: visible !important;
}

.patient-grid.list-view .patient-footer {
    overflow: visible;
}

.patient-grid.list-view .btn-patient-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.patient-grid.list-view .patient-actions-group {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.patient-grid.list-view .btn-patient-reminder {
    min-width: 54px;
    max-width: 68px;
    padding: 0 8px;
    gap: 4px;
    flex-shrink: 0;
}

.patient-grid.list-view .btn-patient-icon-label {
    font-size: 0.64rem;
}

.patient-grid.list-view .btn-patient-reminder .material-symbols-outlined {
    font-size: 15px;
}

.patient-grid.list-view .btn-patient-icon .material-symbols-outlined {
    font-size: 18px;
}

.patient-grid.list-view .patient-gender-badge {
    display: none;
}

.patient-grid.list-view .patient-card.gender-child::after {
    display: none;
}

.patient-grid.list-view .patient-card.is-birthday::before {
    font-size: 20px;
    top: 4px;
    right: 4px;
}

.patient-grid.list-view .av-badge {
    display: none;
}

.patient-grid.list-view .time-ago {
    display: none;
}

.patient-grid.list-view #compras-paciente-panel,
.patient-grid.list-view [id^="compras-paciente-"] {
    left: auto;
    right: 12px;
    width: min(520px, calc(100vw - 48px));
    max-height: min(78vh, 560px);
}

/* Hide checkbox in list view for cleaner look */
.patient-grid.list-view .paciente-checkbox {
    width: 18px !important;
    height: 18px !important;
}

/* Responsive list view */
@media (max-width: 1280px) {
    .patient-grid.list-view .patient-card-front-shell {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
    }

    .patient-grid.list-view .patient-body {
        grid-column: 1 / -1;
        grid-template-columns: minmax(220px, 1.1fr) minmax(180px, 0.9fr) minmax(220px, 1fr);
        padding-top: 0;
        padding-bottom: 12px;
        border-top: 1px solid #f1f5f9;
    }

    .patient-grid.list-view .patient-footer {
        border-left: none;
        padding-left: 12px;
    }
}

@media (max-width: 900px) {
    .patient-grid.list-view .patient-body {
        display: none;
    }

    .patient-grid.list-view .patient-header {
        flex: 1;
    }

    .patient-grid.list-view .patient-card-front-shell {
        display: flex;
    }

    .patient-grid.list-view .patient-footer {
        border-left: 1px solid #f1f5f9;
        padding-left: 14px;
    }
}

@media (max-width: 600px) {
    .patient-grid.list-view .patient-footer .hc-dropdown {
        display: block;
    }

    .patient-grid.list-view .hc-dropdown-content {
        position: fixed;
        bottom: 20px;
        left: 20px;
        right: 20px;
        top: auto;
        width: auto;
        min-width: 0;
        transform: none;
        animation: slideUp 0.3s ease;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.patient-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    perspective: 1800px;
    transition:
        transform 0.3s ease,
        box-shadow 0.35s ease,
        border-color 0.35s ease,
        height 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    height: auto;
    align-self: start;
    animation: cardFadeIn 0.4s ease-out backwards;
}

.patient-card-front-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    background: inherit;
    border-radius: inherit;
    overflow: hidden;
    transition:
        opacity 0.2s ease,
        transform 0.62s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0s linear 0.2s;
    transform-origin: center;
    backface-visibility: hidden;
}

.patient-card.has-purchases-open {
    z-index: 40;
    height: clamp(470px, 70vh, 620px);
    transform: translateY(-2px);
    box-shadow:
        0 18px 42px rgba(15, 23, 42, 0.16),
        0 8px 18px rgba(37, 99, 235, 0.08);
}

.patient-grid.list-view .patient-card.has-purchases-open {
    height: clamp(500px, 72vh, 660px);
    transform: translateY(-2px);
}

.patient-grid.list-view .patient-card.has-purchases-open:hover {
    transform: translateY(-2px);
}

.patient-card.has-purchases-open .patient-card-front-shell {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transform: rotateY(-180deg);
    pointer-events: none;
}

.patient-card.has-purchases-open:hover {
    transform: translateY(-2px);
}

.patient-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.patient-card:hover::after {
    opacity: 1;
}

.patient-card.has-purchases-open::after {
    opacity: 1;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Load More Button */
.btn-load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 30px;
    margin-bottom: 20px;
    width: 100%;
}

.btn-load-more {
    background: white;
    color: #3b82f6;
    border: 2px solid #bfdbfe;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.btn-load-more:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.btn-load-more:active {
    transform: translateY(0);
}

.patient-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
}

/* Gender-specific card styles */
.patient-card.gender-male {
    border-left: 4px solid #3b82f6;
    background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
}

.patient-card.gender-female {
    border-left: 4px solid #ec4899;
    background: linear-gradient(135deg, #fdf2f8 0%, #ffffff 100%);
}

.patient-card.gender-child {
    border-left: 4px solid #a855f7;
    background: linear-gradient(135deg, #faf5ff 0%, #ffffff 100%);
    position: relative;
}

.patient-card.gender-child::after {
    content: '👶';
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 24px;
    opacity: 0.15;
    pointer-events: none;
}

/* Birthday special styling */
.patient-card.is-birthday {
    background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 20%, #ffffff 100%);
    border: 2px solid #fda4af;
    box-shadow: 0 8px 24px rgba(251, 113, 133, 0.2), 0 4px 12px rgba(251, 113, 133, 0.1);
    animation: birthdayPulse 2s ease-in-out infinite;
}

@keyframes birthdayPulse {

    0%,
    100% {
        box-shadow: 0 8px 24px rgba(251, 113, 133, 0.2), 0 4px 12px rgba(251, 113, 133, 0.1);
    }

    50% {
        box-shadow: 0 12px 32px rgba(251, 113, 133, 0.3), 0 6px 16px rgba(251, 113, 133, 0.15);
    }
}

.patient-card.is-birthday::before {
    content: '🎂';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 36px;
    opacity: 0.25;
    transform: rotate(15deg);
    pointer-events: none;
    z-index: 10;
    animation: cakeBounce 1s ease-in-out infinite;
}

@keyframes cakeBounce {

    0%,
    100% {
        transform: rotate(15deg) translateY(0);
    }

    50% {
        transform: rotate(15deg) translateY(-4px);
    }
}

/* Header */
.patient-header {
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid #f1f5f9;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    position: relative;
}

.patient-card.gender-male .patient-header {
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}

.patient-card.gender-female .patient-header {
    background: linear-gradient(135deg, #fdf2f8 0%, #f8fafc 100%);
}

.patient-card.gender-child .patient-header {
    background: linear-gradient(135deg, #faf5ff 0%, #f8fafc 100%);
}

.patient-avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.12rem;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    border: 2px solid #bfdbfe;
    flex-shrink: 0;
    transition: all 0.3s ease;
    position: relative;
}

.patient-avatar::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(59, 130, 246, 0.1));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.patient-card:hover .patient-avatar::before {
    opacity: 1;
}

.patient-avatar.female {
    background: linear-gradient(135deg, #fdf2f8 0%, #fbcfe8 100%);
    color: #db2777;
    border-color: #f9a8d4;
    box-shadow: 0 4px 12px rgba(219, 39, 119, 0.15), inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

.patient-avatar.female::before {
    background: linear-gradient(135deg, rgba(219, 39, 119, 0.2), rgba(236, 72, 153, 0.1));
}

.patient-avatar.child {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    color: #a855f7;
    border-color: #d8b4fe;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.15), inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

.patient-avatar.child::before {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(192, 132, 252, 0.1));
}

.patient-header-info {
    flex: 1;
    min-width: 0;
}

.patient-name {
    font-size: 0.98rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 2px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px 8px;
    letter-spacing: -0.02em;
    line-height: 1.15;
    min-width: 0;
}

.patient-name-text {
    flex: 1 1 180px;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.patient-name-badges {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.patient-history-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(224, 242, 254, 0.72);
    color: #0369a1;
    border: 1px solid #bae6fd;
    font-size: 0.74rem;
    font-weight: 500;
    cursor: help;
}

.patient-history-badge .material-symbols-outlined {
    font-size: 14px;
    opacity: 0.8;
}

.patient-history-badge strong {
    font-size: 0.72rem;
    font-weight: 700;
    opacity: 0.85;
}

.patient-id {
    font-size: 0.7rem;
    color: #64748b;
    font-family: 'Courier New', monospace;
    background: white;
    border: 1px solid #e2e8f0;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
    font-weight: 600;
}

/* Gender badges */
.patient-gender-badge {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffffff;
    z-index: 5;
    transition: all 0.3s ease;
}

.patient-card:hover .patient-gender-badge {
    transform: scale(1.1) rotate(5deg);
}

.patient-gender-badge.male {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.patient-gender-badge.female {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.patient-gender-badge.child {
    background: linear-gradient(135deg, #a855f7, #9333ea);
}

/* Body */
.patient-body {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.patient-purchases-panel {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(191, 219, 254, 0.85);
    z-index: 30;
    opacity: 0;
    transform: rotateY(180deg);
    pointer-events: none;
    transition:
        opacity 0.24s ease,
        transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
    max-height: none;
    backface-visibility: hidden;
    transform-origin: center;
}

.patient-card.has-purchases-open .patient-purchases-panel {
    opacity: 1;
    transform: rotateY(0deg);
    pointer-events: auto;
}

.patient-purchases-shell {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: 100%;
}

.patient-purchases-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fbff 0%, #ffffff 100%);
}

.patient-purchases-kicker {
    font-size: 0.72rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.patient-purchases-title {
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
    word-break: break-word;
}

.patient-purchases-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.patient-purchases-count {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.patient-purchases-close-icon,
.patient-purchases-close {
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.patient-purchases-close-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #f8fafc;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.patient-purchases-close-icon:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.patient-purchases-loading,
.patient-purchases-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 18px;
    color: #64748b;
    text-align: center;
}

.patient-purchases-empty .material-symbols-outlined {
    font-size: 2rem;
    color: #94a3b8;
}

.patient-history-modal-overlay {
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(8px);
    --patient-history-enter-scale: 0.72;
    --patient-history-enter-x: 0px;
    --patient-history-enter-y: 0px;
    --patient-history-origin-x: 50vw;
    --patient-history-origin-y: 50vh;
}

.patient-history-modal {
    width: min(1180px, calc(100% - 28px));
    max-width: 1180px;
    max-height: 95vh;
    overflow: auto;
    border-radius: 28px;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.28);
    opacity: 0;
    transform:
        translate(var(--patient-history-enter-x), var(--patient-history-enter-y))
        scale(var(--patient-history-enter-scale));
    transform-origin: var(--patient-history-origin-x) var(--patient-history-origin-y);
    transition:
        transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform, opacity;
}

.patient-history-modal-overlay.modal-open .patient-history-modal {
    opacity: 1;
    transform: translate(0, 0) scale(1);
}

#patient-history-modal-content,
.patient-history-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: auto;
}

.patient-history-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 32%),
        linear-gradient(135deg, #eff6ff 0%, #ffffff 72%);
}

.patient-history-header-copy {
    min-width: 0;
}

.patient-history-kicker {
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 6px;
}

.patient-history-title {
    font-size: clamp(1.08rem, 1.45vw, 1.45rem);
    font-weight: 900;
    color: #0f172a;
    line-height: 1.1;
    word-break: break-word;
}

.patient-history-subtitle {
    margin-top: 4px;
    color: #475569;
    font-size: 0.84rem;
    font-weight: 600;
}

.patient-history-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.patient-history-sync {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.patient-history-sync.syncing {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.patient-history-sync.ready {
    background: #ecfdf5;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.patient-history-sync .material-symbols-outlined {
    font-size: 1rem;
}

.patient-history-ghost-btn {
    border: 1px solid #cbd5e1;
    background: white;
    color: #0f172a;
    border-radius: 12px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.patient-history-ghost-btn:hover {
    transform: translateY(-1px);
    border-color: #93c5fd;
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.12);
}

.patient-history-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 12px 18px 0;
}

.patient-history-summary-card {
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.patient-history-summary-card small {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.patient-history-summary-card strong {
    font-size: 0.95rem;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.05;
}

.patient-history-summary-card span {
    color: #475569;
    font-size: 0.76rem;
    font-weight: 600;
}

.patient-history-summary-card.accent {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border-color: #bfdbfe;
}

.patient-history-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.95fr);
    gap: 12px;
    padding: 12px 18px 18px;
    min-height: 0;
    flex: 1;
}

.patient-history-section {
    min-height: 0;
    border: 1px solid #dbe5f1;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.patient-history-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.92);
}

.patient-history-section-title-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.patient-history-section-head-side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.section-head-action-btn {
    min-height: 36px;
    padding: 8px 14px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

.patient-history-section-head h3 {
    margin: 2px 0 0;
    font-size: 0.92rem;
    font-weight: 900;
    color: #0f172a;
}

.patient-history-section-kicker {
    font-size: 0.64rem;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.patient-history-section-body {
    padding: 12px;
    min-height: 0;
    overflow: visible;
}

.purchase-history-list.modal-mode,
.patient-order-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.purchase-history-list.modal-mode {
    padding: 10px;
}

.patient-history-section-body.purchase-history-list.modal-mode {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(64vh, 760px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
}

.patient-history-section-empty {
    min-height: 220px;
    border: 1px dashed #cbd5e1;
    border-radius: 18px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    color: #64748b;
    padding: 20px;
}

.patient-history-section-empty .material-symbols-outlined {
    font-size: 2.2rem;
    color: #94a3b8;
}

.patient-history-section-empty strong {
    color: #0f172a;
    font-size: 1rem;
}

.patient-order-card {
    border: 1px solid #dbe5f1;
    border-radius: 18px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.patient-order-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.patient-order-card-head-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.patient-order-card-kicker {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 6px;
}

.patient-order-card-title {
    font-size: 1rem;
    font-weight: 900;
    color: #0f172a;
    line-height: 1.2;
}

.patient-order-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    white-space: nowrap;
}

.patient-order-state .material-symbols-outlined {
    font-size: 1rem;
}

.patient-order-state.pedido {
    background: #fef3c7;
    color: #b45309;
}

.patient-order-state.laboratorio {
    background: #ffedd5;
    color: #c2410c;
}

.patient-order-state.listo {
    background: #dcfce7;
    color: #15803d;
}

.patient-order-state.entregado {
    background: #dbeafe;
    color: #1d4ed8;
}

.patient-order-state.cotizado {
    background: #e2e8f0;
    color: #475569;
}

.patient-order-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.patient-order-meta-item {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 12px;
    background: #ffffff;
    min-width: 0;
}

.patient-order-meta-item small {
    display: block;
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.patient-order-meta-item strong {
    display: block;
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 800;
    word-break: break-word;
}

.patient-order-provider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.patient-order-provider-row .material-symbols-outlined {
    font-size: 1.25rem;
    color: #2563eb;
}

.patient-order-provider-title {
    color: #0f172a;
    font-weight: 800;
    font-size: 0.92rem;
}

.patient-order-provider-subtitle {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 2px;
}

.patient-order-actions {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 980px) {
    .patient-history-modal {
        width: min(100%, calc(100% - 18px));
        max-height: 94vh;
        border-radius: 22px;
    }

    .patient-history-summary,
    .patient-history-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .patient-history-header {
        padding: 18px 16px 14px;
    }

    .patient-history-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .patient-history-summary {
        padding: 14px 16px 0;
    }

    .patient-history-grid {
        padding: 14px 16px 16px;
    }

    .patient-history-section-head {
        padding: 14px 14px 12px;
    }

    .patient-history-section-body,
    .purchase-history-list.modal-mode {
        padding: 12px;
    }

    .patient-order-meta-grid {
        grid-template-columns: 1fr;
    }
}

.patient-contact {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.patient-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.84rem;
    color: #475569;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    transition: all 0.25s ease;
    min-width: 0;
}

.patient-contact-item>*:last-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.patient-contact-item:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #f8fafc 100%);
    border-color: #cbd5e1;
    transform: translateX(4px);
}

.patient-contact-item .material-symbols-outlined {
    font-size: 1rem;
    color: #64748b;
    transition: color 0.25s ease;
}

.patient-contact-item:hover .material-symbols-outlined {
    color: #3b82f6;
}

.patient-contact-item a {
    color: #334155;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.25s ease;
}

.patient-contact-item a:hover {
    color: #0284c7;
}

.patient-note-card {
    margin-top: 0;
    padding: 8px 10px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    min-height: 62px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.patient-note-card.empty {
    background: linear-gradient(135deg, #fafcff 0%, #f8fafc 100%);
}

.patient-note-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    color: #475569;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.patient-note-text {
    color: #334155;
    font-size: 0.8rem;
    line-height: 1.28;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    min-height: calc(1.28em * 2);
}

.patient-note-card.empty .patient-note-text {
    color: #94a3b8;
    font-style: italic;
}

/* Clinical Info */
.patient-clinical {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 2px;
}

.clinical-stat {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 6px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 58px;
}

.clinical-stat:hover {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.clinical-label {
    font-size: 0.58rem;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 800;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.clinical-val {
    font-size: 0.75rem;
    font-weight: 800;
    color: #0f172a;
    width: 100%;
    text-align: center;
    line-height: 1.1;
}

.clinical-val.highlight {
    color: #3b82f6;
    font-size: 0.82rem;
}

.clinical-val.empty {
    color: #cbd5e1;
    font-weight: 500;
    font-style: italic;
}

/* === VISIT STATUS SEMAPHORE === */
.visit-status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 5px;
    border-radius: 8px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    transition: all 0.3s ease;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.visit-status-indicator.status-active {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.visit-status-indicator.status-warning {
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
    color: #a16207;
    border: 1px solid #fde68a;
}

.visit-status-indicator.status-overdue {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #b91c1c;
    border: 1px solid #fecaca;
    animation: pulseOverdue 3s ease-in-out infinite;
}

.visit-status-indicator.status-none {
    background: #f8fafc;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
}

@keyframes pulseOverdue {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.visit-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-active .visit-status-dot {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-warning .visit-status-dot {
    background: #eab308;
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.5);
}

.status-overdue .visit-status-dot {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.status-none .visit-status-dot {
    background: #cbd5e1;
}

/* === PROFILE COMPLETENESS BAR === */
.profile-completeness {
    padding: 8px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-completeness::before {
    content: 'Completitud de perfil';
    font-size: 0.58rem;
    color: #94a3b8;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.completeness-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.completeness-bar-track {
    flex: 1;
    height: 4px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.completeness-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
    background-size: 200% 100%;
    position: relative;
}

.completeness-bar-fill[data-pct="100"] {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.completeness-bar-fill[data-pct="0"] {
    background: #ef4444;
}

.completeness-label {
    font-size: 0.62rem;
    font-weight: 700;
    color: #94a3b8;
    white-space: nowrap;
    min-width: 28px;
    text-align: right;
}

.completeness-label.complete {
    color: #16a34a;
}

.completeness-label.incomplete {
    color: #f59e0b;
}

.completeness-label.critical {
    color: #ef4444;
}

/* === VISUAL ACUITY BADGE === */
.av-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    margin-left: 6px;
    transition: all 0.3s ease;
}

.av-badge.av-normal {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.av-badge.av-mild {
    background: linear-gradient(135deg, #fefce8, #fef9c3);
    color: #a16207;
    border: 1px solid #fde68a;
}

.av-badge.av-moderate {
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    color: #c2410c;
    border: 1px solid #fed7aa;
}

.av-badge.av-severe {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.patient-card:hover .av-badge {
    transform: scale(1.05);
}

/* === PATIENT CLINICAL GRID — 3 columns when status is present === */
.patient-clinical.has-status {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* === TIEMPO TRANSCURRIDO LEGIBLE === */
.time-ago {
    display: block;
    font-size: 0.54rem;
    font-weight: 600;
    margin-top: 1px;
    opacity: 0.7;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer Actions */
.patient-footer {
    padding: 10px 16px 12px;
    border-top: 2px solid #f1f5f9;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 8px;
    flex-wrap: wrap;
    /* Allow wrapping */
}

.hc-dropdown {
    flex: 1 1 180px;
}

.btn-patient-history {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-patient-history:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.timeline-btn {
    color: #7c3aed;
    background: #f5f3ff;
    border-color: #ddd6fe;
}

.timeline-btn:hover {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
}

.patient-actions-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-patient-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-patient-icon:hover {
    transform: translateY(-2px);
    background: #f1f5f9;
    color: #334155;
}

.btn-patient-reminder {
    width: auto;
    min-width: 40px;
    height: 32px;
    padding: 0 10px;
    gap: 6px;
    font-weight: 600;
    border-color: #dbeafe;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    color: #0369a1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.btn-patient-reminder:hover {
    background: #eff6ff;
    color: #075985;
    border-color: #93c5fd;
}

.btn-patient-reminder .material-symbols-outlined {
    font-size: 16px;
}

.btn-patient-icon-label {
    font-size: 0.68rem;
    line-height: 1;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.btn-patient-icon.primary {
    background: #eff6ff;
    color: #2563eb;
}

.btn-patient-icon.primary:hover {
    background: #2563eb;
    color: white;
}

.btn-patient-icon.success {
    background: #f0fdf4;
    color: #16a34a;
}

.btn-patient-icon.success:hover {
    background: #16a34a;
    color: white;
}

.btn-patient-icon.reminder-due {
    background: linear-gradient(135deg, #dc2626, #f97316);
    color: #fff;
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.28);
}

.btn-patient-icon.reminder-due:hover {
    background: linear-gradient(135deg, #b91c1c, #ea580c);
    color: #fff;
}

.btn-patient-icon.reminder-soon {
    background: linear-gradient(135deg, #facc15, #f59e0b);
    color: #713f12;
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.24);
}

.btn-patient-icon.reminder-soon:hover {
    background: linear-gradient(135deg, #eab308, #d97706);
    color: #fff;
}

.btn-patient-icon.warning {
    background: #fffbeb;
    color: #d97706;
}

.btn-patient-icon.warning:hover {
    background: #d97706;
    color: white;
}

.btn-patient-icon.danger {
    background: #fef2f2;
    color: #ef4444;
}

.btn-patient-icon.danger:hover {
    background: #ef4444;
    color: white;
}

.patient-reminder-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #dc2626, #f97316);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 16px rgba(249, 115, 22, 0.22);
}

.patient-reminder-badge.is-soon {
    background: linear-gradient(135deg, #facc15, #f59e0b);
    color: #713f12;
    box-shadow: 0 8px 16px rgba(245, 158, 11, 0.22);
}

/* --- PURCHASE HISTORY STYLES --- */
.purchase-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

.purchase-history-list::-webkit-scrollbar {
    width: 4px;
}

.purchase-history-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.purchase-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.purchase-item:hover {
    background: white;
    border-color: #3b82f6;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transform: translateX(2px);
}

.purchase-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: white;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    flex-shrink: 0;
    overflow: hidden;
    /* Prevent text spill if font fails */
}

.purchase-info {
    flex: 1;
    min-width: 0;
}

.purchase-desc {
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
    white-space: normal;
    /* Allow wrapping */
    line-height: 1.3;
    margin-bottom: 2px;
}

.purchase-meta {
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    gap: 6px;
    align-items: center;
    font-weight: 500;
}

.purchase-amount {
    font-weight: 800;
    color: #0f172a;
    font-size: 0.95rem;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
}

.purchase-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.purchase-action-btn:hover {
    background: #eff6ff;
    color: #3b82f6;
}

/* --- REFACTORED PURCHASE HISTORY LAYOUT (2-ROW SYSTEM) --- */
.purchase-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    max-height: none;
    overflow-y: auto;
    padding: 12px 14px 6px;
}

.purchase-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid #dbe4f0;
    transition: all 0.2s ease;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.purchase-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.12);
    background: #f8fbff;
}

.purchase-item.is-abono {
    border-color: #bae6fd;
    background: linear-gradient(180deg, #f8fdff 0%, #ffffff 100%);
}

/* Unified Header */
.purchase-sale-header-unified {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eef2f7;
    flex-wrap: wrap;
}

.purchase-sale-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.purchase-sale-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.purchase-item.is-abono .purchase-sale-icon-box {
    background: #ecfeff;
    color: #0891b2;
}

.purchase-sale-header-info {
    display: flex;
    flex-direction: column;
}

.purchase-sale-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
}

.purchase-sale-date {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 2px;
    font-weight: 500;
}

.purchase-sale-badges-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.purchase-items-table {
    border: 1px solid #dbe5f1;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
}

.purchase-items-table.compact {
    padding: 0;
    background: #f8fafc;
    border: 0;
}

.purchase-items-head,
.purchase-items-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1.8fr) minmax(72px, 0.85fr) minmax(84px, 0.95fr);
    gap: 8px;
    align-items: start;
}

.purchase-items-head {
    background: #0f172a;
    color: white;
    padding: 8px 9px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.purchase-items-row {
    padding: 8px 9px;
    font-size: 0.78rem;
    color: #334155;
    background: #ffffff;
    border-top: 1px solid #eef2f7;
}

.purchase-items-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.purchase-item-label {
    display: none;
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.purchase-items-row.alt {
    background: #f8fafc;
}

.purchase-items-qty {
    text-align: center;
}

.purchase-items-qty strong {
    font-weight: 800;
    color: #0f172a;
    font-size: 0.92rem;
}

.purchase-items-name {
    word-break: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

.purchase-items-name span:last-child,
.purchase-items-unit span:last-child {
    word-break: normal;
    overflow-wrap: anywhere;
}

.purchase-items-unit,
.purchase-items-total {
    text-align: right;
}

.purchase-items-total {
    color: #0f172a;
}

.purchase-items-total strong {
    font-weight: 800;
    font-size: 0.88rem;
}

.purchase-sale-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
}

.purchase-sale-content.has-summary {
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.95fr);
    align-items: start;
}

.purchase-sale-products,
.purchase-sale-summary {
    min-width: 0;
}

.purchase-items-body.compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.purchase-product-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "desc desc"
        "meta total";
    gap: 8px 12px;
    align-items: end;
    padding: 10px 12px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    min-width: 0;
    height: 100%;
}

.purchase-product-card.alt {
    background: #f8fafc;
}

.purchase-product-desc {
    grid-area: desc;
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: #334155;
    line-height: 1.25;
    word-break: normal;
    overflow-wrap: anywhere;
}

.purchase-product-total {
    grid-area: total;
    min-width: 0;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
}

.purchase-product-total span,
.purchase-product-chip span {
    font-size: 0.66rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.purchase-product-total strong {
    font-size: 0.84rem;
    color: #0f172a;
}

.purchase-product-meta {
    grid-area: meta;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.purchase-product-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #dbe5f1;
}

.purchase-product-chip strong {
    font-size: 0.78rem;
    color: #0f172a;
}

.purchase-abono-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    width: 100%;
}

.purchase-abono-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 800;
    color: #0369a1;
}

.purchase-abono-desc,
.purchase-note-box {
    color: #334155;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
}

.purchase-note-box {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.purchase-abono-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.purchase-abono-metric,
.purchase-total-chip {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #d7e7f3;
}

.purchase-abono-metric span {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.purchase-abono-metric strong {
    color: #0f172a;
    font-size: 0.88rem;
}

/* Inline Totals */
.purchase-sale-totals-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
}

.purchase-summary-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 0.8rem;
}

.purchase-summary-row span {
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
}

.purchase-summary-row strong {
    color: #0f172a;
    font-weight: 800;
    font-size: 0.9rem;
}

.purchase-summary-row.highlight {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.purchase-summary-row.highlight span {
    color: #2563eb;
}

.purchase-summary-row.highlight strong {
    color: #1d4ed8;
}

.purchase-summary-row.danger {
    background: #fff1f2;
    border-color: #fecdd3;
}

.purchase-summary-row.danger span,
.purchase-summary-row.danger strong {
    color: #be123c;
}

.purchase-summary-row.subtle {
    background: #ffffff;
    border-color: #e2e8f0;
}

.purchase-sale-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
}

.badge-pago {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #475569;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.purchase-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.purchase-action-btn:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

.purchase-action-btn.action-pill {
    width: auto;
    height: auto;
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 999px;
    border-color: #dbeafe;
    background: #f8fbff;
    color: #1d4ed8;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 800;
}

.purchase-action-btn.action-pill.primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.22);
}

.purchase-action-btn.action-pill .material-symbols-outlined {
    font-size: 1rem;
}

.purchase-action-btn.action-pill:hover {
    transform: translateY(-1px);
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #93c5fd;
}

.purchase-action-btn.action-pill.primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    color: #ffffff;
    border-color: transparent;
}

.patient-purchases-more,
.patient-purchases-footer {
    padding: 10px 14px 14px;
}

.patient-purchases-more {
    padding-top: 6px;
}

.patient-purchases-more-btn,
.patient-purchases-close {
    width: 100%;
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 0.86rem;
    font-weight: 700;
}

.patient-purchases-more-btn {
    border: 1px dashed #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
    cursor: pointer;
}

.patient-purchases-more-btn:hover {
    background: #dbeafe;
}

.patient-purchases-close {
    background: #0f172a;
    color: white;
}

.patient-purchases-close:hover {
    background: #1e293b;
}

@media (max-width: 640px) {
    .patient-purchases-panel {
        inset: 0;
    }
}

@media (max-width: 980px) {
    .patient-card.has-purchases-open {
        height: clamp(500px, 76vh, 680px);
    }

    .purchase-sale-content.has-summary {
        grid-template-columns: 1fr;
    }

    .purchase-items-table {
        padding: 10px;
        background: #f8fafc;
    }

    .purchase-items-head {
        display: none;
    }

    .purchase-items-body {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .purchase-items-body.compact {
        gap: 8px;
    }

    .purchase-product-card {
        grid-template-columns: 1fr;
        grid-template-areas:
            "desc"
            "meta"
            "total";
        align-items: flex-start;
    }

    .purchase-product-total {
        min-width: 0;
        width: 100%;
        text-align: left;
        align-items: flex-start;
    }

    .purchase-product-meta {
        justify-content: flex-start;
    }

    .purchase-items-row,
    .purchase-items-row.alt {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        padding: 12px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background: #ffffff;
    }

    .purchase-items-name {
        grid-column: 1 / -1;
    }

    .purchase-item-label {
        display: block;
    }

    .purchase-items-qty,
    .purchase-items-unit,
    .purchase-items-total {
        text-align: left;
    }

    .purchase-abono-grid {
        grid-template-columns: 1fr;
    }
}

/* Modal Overlay Class - Added for Consentimientos */
.premium-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    /* removed backdrop-filter */
    /* removed -webkit-backdrop-filter */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

/* Dropdown para Historias Clínicas en tarjeta de paciente */
.hc-dropdown {
    position: relative;
    display: inline-block;
}

.hc-dropdown-content {
    display: none;
    position: absolute;
    bottom: 110%;
    /* Aparece hacia arriba */
    left: 0;
    background-color: #fff;
    min-width: 220px;
    box-shadow: 0px 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    animation: hcSlideUp 0.2s ease;
}

@keyframes hcSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hc-dropdown-content a {
    color: #334155;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.hc-dropdown-content a:last-child {
    border-bottom: none;
}

.hc-dropdown-content a:hover {
    background-color: #f8fafc;
    color: #4f46e5;
}

.hc-dropdown.active .hc-dropdown-content {
    display: block;
}

.hc-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #6366f1;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
    transition: all 0.2s;
    width: 100%;
}

.hc-dropdown-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.3);
    background: #4f46e5;
}

.hc-dropdown-trigger:after {
    content: ' \25BE';
    /* Flecha abajo */
    font-size: 0.8rem;
}

.hc-dropdown-trigger .material-symbols-outlined {
    font-size: 20px;
}

@media (max-width: 900px) {
    .patient-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 16px;
    }

    .patient-header {
        padding: 14px 16px 10px;
        gap: 10px;
    }

    .patient-avatar {
        width: 46px;
        height: 46px;
        border-radius: 12px;
        font-size: 1.1rem;
    }

    .patient-name {
        font-size: 0.94rem;
        margin-bottom: 3px;
        line-height: 1.08;
    }

    .patient-name-text {
        -webkit-line-clamp: 1;
    }

    .patient-id {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .patient-body {
        padding: 12px 16px;
        gap: 9px;
    }

    .patient-contact {
        gap: 8px;
    }

    .patient-contact-item {
        padding: 8px 12px;
        font-size: 0.84rem;
        border-radius: 12px;
    }

    .patient-contact-item .material-symbols-outlined {
        font-size: 1rem;
    }

    .patient-note-card {
        margin-top: 0 !important;
        padding: 8px 10px !important;
        border-radius: 12px !important;
        min-height: 68px;
    }

    .patient-note-label {
        margin-bottom: 4px !important;
        font-size: 0.66rem !important;
    }

    .patient-note-text {
        font-size: 0.8rem !important;
        line-height: 1.3 !important;
        -webkit-line-clamp: 2 !important;
        min-height: calc(1.3em * 2);
    }

    .patient-clinical,
    .patient-clinical.has-status {
        gap: 6px;
    }

    .clinical-stat {
        min-height: 64px;
        padding: 8px 6px;
        border-radius: 12px;
    }

    .clinical-label {
        font-size: 0.56rem;
        margin-bottom: 2px;
    }

    .clinical-val {
        font-size: 0.75rem;
        line-height: 1.1;
    }

    .clinical-val.highlight {
        font-size: 0.82rem;
    }

    .time-ago {
        font-size: 0.55rem;
        margin-top: 1px;
    }

    .visit-status-indicator {
        gap: 4px;
        padding: 4px 5px;
        font-size: 0.62rem;
    }

    .visit-status-dot {
        width: 7px;
        height: 7px;
    }

    .profile-completeness {
        padding: 8px 16px 0;
        gap: 2px;
    }

    .profile-completeness::before {
        font-size: 0.58rem;
    }

    .completeness-bar-track {
        height: 4px;
    }

    .completeness-label {
        font-size: 0.62rem;
        min-width: 28px;
    }

    .patient-footer {
        padding: 10px 16px 12px;
        gap: 8px;
        align-items: center;
    }

    .hc-dropdown {
        flex: 1 1 180px;
    }

    .hc-dropdown-trigger {
        padding: 9px 14px;
        border-radius: 10px;
        font-size: 0.8rem;
    }

    .patient-actions-group {
        gap: 6px;
    }

    .btn-patient-icon {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }
}

@media (max-width: 640px) {
    .patient-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .patient-card {
        border-radius: 16px;
    }

    .patient-header {
        padding: 14px 14px 12px;
        gap: 10px;
    }

    .patient-avatar {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        font-size: 1.15rem;
    }

    .patient-name {
        font-size: 0.96rem;
        margin-bottom: 6px;
    }

    .patient-name-text {
        flex-basis: 100%;
    }

    .patient-body {
        padding: 12px 14px;
        gap: 10px;
    }

    .patient-contact {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .patient-contact-item {
        padding: 9px 12px;
        font-size: 0.84rem;
        border-radius: 12px;
    }

    .patient-contact-item .material-symbols-outlined {
        font-size: 1rem;
    }

    .patient-note-card {
        margin-top: 0 !important;
        padding: 10px 12px !important;
        border-radius: 12px !important;
        min-height: 72px;
    }

    .patient-note-label {
        margin-bottom: 6px !important;
        font-size: 0.68rem !important;
    }

    .patient-note-text {
        font-size: 0.82rem !important;
        line-height: 1.35 !important;
        -webkit-line-clamp: 2 !important;
        min-height: calc(1.35em * 2);
    }

    .patient-clinical,
    .patient-clinical.has-status {
        gap: 8px;
    }

    .clinical-stat {
        min-height: 78px;
        padding: 10px 6px;
        border-radius: 14px;
    }

    .clinical-label {
        font-size: 0.6rem;
    }

    .clinical-val {
        font-size: 0.78rem;
    }

    .clinical-val.highlight {
        font-size: 0.88rem;
    }

    .visit-status-indicator {
        padding: 5px 6px;
        font-size: 0.65rem;
    }

    .profile-completeness {
        padding: 10px 14px 0;
    }

    .patient-footer {
        padding: 12px 14px 14px;
        gap: 10px;
    }

    .hc-dropdown,
    .patient-actions-group {
        width: 100%;
    }

    .patient-actions-group {
        justify-content: flex-start;
    }

    .btn-patient-icon {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }
}

.cmr-shell {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 8px 4px 28px;
}

.cmr-hero,
.cmr-composer-card,
.cmr-list-card,
.cmr-stat-card,
.cmr-patient-card,
.cmr-empty-state {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    border: 1px solid rgba(203, 213, 225, 0.9);
    border-radius: 20px;
    box-shadow: 0 18px 45px -28px rgba(15, 23, 42, 0.28);
}

.cmr-hero {
    padding: 22px;
    display: grid;
    gap: 18px;
    background:
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.14), transparent 36%),
        linear-gradient(135deg, rgba(14, 165, 233, 0.05), rgba(99, 102, 241, 0.05)),
        #fff;
}

.cmr-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cmr-hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cmr-hero-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.global-updates-trigger {
    position: relative;
}

.global-updates-trigger.has-unread::after,
.global-updates-trigger.is-open::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 18px;
    border: 1px solid rgba(14, 165, 233, 0.22);
    pointer-events: none;
}

.global-updates-trigger.has-unread:not(.is-open) {
    animation: globalUpdatesPulse 1.8s ease-in-out infinite;
}

.global-updates-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 18px -14px rgba(239, 68, 68, 1);
}

.global-updates-panel {
    padding: 18px;
    border-radius: 22px;
    border: 1px solid rgba(191, 219, 254, 0.95);
    background: rgba(255, 255, 255, 0.985);
    box-shadow: 0 30px 65px -36px rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(12px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.global-updates-panel.is-empty {
    max-width: 430px;
}

.global-updates-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.global-updates-kicker {
    display: inline-flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.1);
    color: #0369a1;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.global-updates-head strong {
    display: block;
    margin-bottom: 4px;
    color: #0f172a;
}

.global-updates-head p,
.global-updates-meta,
.global-updates-item p,
.global-updates-preview-head span {
    margin: 0;
    color: #64748b;
    line-height: 1.45;
}

.global-updates-close {
    width: 36px;
    height: 36px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #f8fbff;
    color: #0369a1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.global-updates-meta {
    margin-bottom: 14px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.global-updates-list {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.global-updates-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.94), rgba(239, 246, 255, 0.94));
    border: 1px solid #dbeafe;
}

.global-updates-item.is-new {
    border-color: rgba(14, 165, 233, 0.4);
    background: linear-gradient(135deg, rgba(236, 253, 245, 0.96), rgba(239, 246, 255, 0.96));
    box-shadow: 0 22px 38px -30px rgba(14, 165, 233, 0.7);
}

.global-updates-item .material-symbols-outlined {
    color: #0284c7;
    font-size: 1.35rem;
}

.global-updates-item-status {
    display: inline-flex;
    align-items: center;
    margin-bottom: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.global-updates-item.is-new .global-updates-item-status {
    background: rgba(14, 165, 233, 0.14);
    color: #0369a1;
}

.global-updates-item strong {
    display: block;
    margin-bottom: 4px;
    color: #0f172a;
}

.global-updates-delete {
    width: 34px;
    height: 34px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #fff;
    color: #ef4444;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.global-updates-delete:hover {
    transform: translateY(-1px);
    border-color: rgba(239, 68, 68, 0.28);
    box-shadow: 0 14px 28px -22px rgba(239, 68, 68, 0.9);
}

.global-updates-empty {
    padding: 18px;
    border-radius: 18px;
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    display: grid;
    gap: 8px;
    justify-items: start;
}

.global-updates-empty .material-symbols-outlined {
    color: #94a3b8;
    font-size: 1.5rem;
}

.global-updates-empty strong {
    color: #0f172a;
}

.global-updates-empty p {
    margin: 0;
    color: #64748b;
    line-height: 1.45;
}

.global-updates-preview {
    padding: 14px;
    border-radius: 18px;
    background: #0f172a;
    color: #e2e8f0;
    margin-bottom: 14px;
}

.global-updates-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.global-updates-preview-head strong {
    color: #f8fafc;
}

.global-updates-preview pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    line-height: 1.55;
}

.global-updates-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.global-updates-actions.is-empty {
    justify-content: flex-end;
}

.global-updates-action-btn {
    min-height: 42px;
}

.global-updates-action-btn.is-danger {
    border-color: rgba(239, 68, 68, 0.28);
    color: #b91c1c;
}

@keyframes globalUpdatesPulse {
    0%,
    100% {
        transform: translateY(0);
        box-shadow: 0 10px 24px -18px rgba(14, 165, 233, 0.4);
    }
    50% {
        transform: translateY(-1px);
        box-shadow: 0 16px 30px -18px rgba(14, 165, 233, 0.65);
    }
}

.cmr-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.1);
    color: #0369a1;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cmr-mini-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0369a1;
}

.cmr-hero h2 {
    margin: 10px 0 4px;
    font-size: clamp(1.45rem, 2vw, 2rem);
    color: #0f172a;
    line-height: 1.08;
}

.cmr-hero p,
.cmr-list-head p,
.cmr-composer-head p,
.cmr-empty-state p,
.cmr-helper,
.cmr-preview-head span {
    margin: 0;
    color: #64748b;
    line-height: 1.5;
}

.cmr-hero-board {
    display: grid;
    grid-template-columns: minmax(210px, 1fr) minmax(220px, 1.2fr) minmax(220px, 1fr) minmax(170px, 0.9fr);
    gap: 12px;
    align-items: stretch;
}

.cmr-focus-card,
.cmr-patient-mini-card,
.cmr-hero-hint,
.cmr-data-pill {
    border-radius: 18px;
    border: 1px solid #dbeafe;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
}

.cmr-focus-card {
    padding: 14px 16px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.cmr-focus-card .material-symbols-outlined {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 165, 233, 0.12);
    color: #0284c7;
    font-size: 1.25rem;
}

.cmr-focus-card small,
.cmr-patient-mini-copy small {
    display: block;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cmr-focus-card strong,
.cmr-patient-mini-copy strong {
    display: block;
    margin-top: 2px;
    color: #0f172a;
}

.cmr-focus-card.is-danger {
    border-color: #fecaca;
    background: linear-gradient(180deg, #fff7f7, #fff1f2);
}

.cmr-focus-card.is-warning {
    border-color: #fde68a;
    background: linear-gradient(180deg, #fffdf5, #fffbeb);
}

.cmr-focus-card.is-success {
    border-color: #bbf7d0;
    background: linear-gradient(180deg, #f7fff9, #f0fdf4);
}

.cmr-focus-card.is-brand {
    border-color: #bfdbfe;
    background: linear-gradient(180deg, #f8fbff, #eff6ff);
}

.cmr-hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.cmr-hero-metric {
    padding: 12px;
    border-radius: 18px;
    background: rgba(248, 250, 252, 0.98);
    border: 1px solid #e2e8f0;
    display: grid;
    gap: 4px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.cmr-hero-metric:hover,
.cmr-focus-card:hover,
.cmr-patient-mini-card:hover,
.cmr-hero-hint:hover,
.cmr-data-pill:hover,
.cmr-stat-card:hover,
.cmr-patient-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 35px -28px rgba(37, 99, 235, 0.4);
    border-color: rgba(56, 189, 248, 0.35);
}

.cmr-hero-metric span {
    color: #64748b;
    font-size: 0.8rem;
}

.cmr-hero-metric strong {
    color: #0f172a;
    font-size: 1.3rem;
    line-height: 1;
}

.cmr-patient-mini-card {
    padding: 12px 14px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.cmr-patient-mini-avatar {
    width: 42px;
    height: 42px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: #fff;
    font-weight: 800;
}

.cmr-patient-mini-copy span {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 0.9rem;
}

.cmr-hero-hint {
    padding: 12px 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
}

.cmr-hero-hint .material-symbols-outlined {
    color: #0284c7;
}

.cmr-data-pill {
    padding: 12px 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #334155;
    font-size: 0.88rem;
    font-weight: 700;
}

.cmr-data-pill .material-symbols-outlined {
    color: #0284c7;
}

.cmr-data-pill.is-loading .material-symbols-outlined {
    animation: cmrSpin 1s linear infinite;
}

.cmr-stats-grid,
.cmr-segment-list,
.cmr-composer-grid,
.cmr-patient-meta,
.cmr-patient-actions,
.cmr-inline-actions {
    display: grid;
    gap: 12px;
}

.cmr-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.cmr-stat-card {
    padding: 18px 20px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.cmr-stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 165, 233, 0.12);
}

.cmr-stat-card .material-symbols-outlined {
    font-size: 1.5rem;
    color: #0ea5e9;
}

.cmr-stat-copy {
    display: grid;
    gap: 4px;
}

.cmr-stat-card strong {
    font-size: 1.85rem;
    line-height: 1;
    color: #0f172a;
}

.cmr-stat-card small {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cmr-stat-card span {
    margin: 0;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
}

.cmr-stat-card.tone-danger .cmr-stat-icon {
    background: rgba(239, 68, 68, 0.12);
}

.cmr-stat-card.tone-danger .material-symbols-outlined {
    color: #dc2626;
}

.cmr-stat-card.tone-success .cmr-stat-icon {
    background: rgba(34, 197, 94, 0.12);
}

.cmr-stat-card.tone-success .material-symbols-outlined {
    color: #16a34a;
}

.cmr-stat-card.tone-warning .cmr-stat-icon {
    background: rgba(245, 158, 11, 0.14);
}

.cmr-stat-card.tone-warning .material-symbols-outlined {
    color: #d97706;
}

.cmr-segment-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.cmr-segment-btn {
    border: 1px solid rgba(203, 213, 225, 0.95);
    background: #fff;
    color: #334155;
    border-radius: 18px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.cmr-segment-btn .material-symbols-outlined {
    color: #0284c7;
}

.cmr-segment-copy {
    display: grid;
    gap: 2px;
}

.cmr-segment-copy small {
    color: #64748b;
    font-size: 0.77rem;
    font-weight: 600;
}

.cmr-segment-btn strong {
    margin-left: auto;
    min-width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 165, 233, 0.1);
    color: #0369a1;
    font-size: 0.88rem;
}

.cmr-segment-btn:hover,
.cmr-segment-btn.active {
    transform: translateY(-1px);
    border-color: rgba(14, 165, 233, 0.5);
    box-shadow: 0 16px 35px -26px rgba(14, 165, 233, 0.7);
}

.cmr-segment-btn.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(59, 130, 246, 0.1));
    color: #0f172a;
}

.cmr-segment-btn.active::after {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    background: linear-gradient(90deg, #0ea5e9, #2563eb);
}

.cmr-layout {
    display: grid;
    grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.cmr-composer-card,
.cmr-list-card {
    padding: 22px;
}

.cmr-composer-card {
    position: sticky;
    top: 18px;
}

.cmr-composer-head,
.cmr-list-head,
.cmr-preview-head,
.cmr-patient-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.cmr-composer-head h3,
.cmr-list-head h3,
.cmr-patient-head h4 {
    margin: 0 0 4px;
    color: #0f172a;
}

.cmr-composer-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.cmr-inline-actions {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    align-items: center;
}

.cmr-composer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    margin: 18px 0 14px;
}

.cmr-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cmr-field-search {
    grid-column: span 1;
}

.cmr-field label,
.cmr-checkbox span {
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
}

.cmr-field input,
.cmr-field select,
.cmr-field textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.cmr-field textarea {
    min-height: 170px;
    resize: vertical;
}

.cmr-field input:focus,
.cmr-field select:focus,
.cmr-field textarea:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12);
}

.cmr-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid #dbeafe;
    background: #f8fbff;
}

.cmr-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: #0284c7;
}

.cmr-helper {
    font-size: 0.78rem;
}

.cmr-selected-patient {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid #dbeafe;
    background: linear-gradient(135deg, rgba(248, 252, 255, 0.98), rgba(239, 246, 255, 0.98));
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px 14px;
    align-items: start;
}

.cmr-selected-patient.empty {
    grid-template-columns: 1fr;
    justify-items: start;
}

.cmr-selected-patient.empty .material-symbols-outlined {
    color: #0284c7;
    font-size: 1.3rem;
}

.cmr-selected-avatar,
.cmr-patient-avatar {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.03em;
    box-shadow: 0 16px 28px -20px rgba(37, 99, 235, 0.8);
}

.cmr-selected-copy strong {
    display: block;
    color: #0f172a;
}

.cmr-selected-copy p {
    margin: 4px 0 0;
}

.cmr-selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.cmr-selected-meta {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.cmr-selected-meta span {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.78);
    color: #475569;
    font-size: 0.87rem;
}

.cmr-selected-meta strong {
    color: #0f172a;
}

.cmr-preview-card {
    margin-top: 16px;
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 0.98));
    border: 1px solid #e2e8f0;
    color: #334155;
}

.cmr-preview-head {
    margin-bottom: 12px;
}

.cmr-preview-head strong {
    color: #0f172a;
}

.cmr-preview-card pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    line-height: 1.6;
    font-size: 0.95rem;
}

.cmr-variable-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.cmr-variable-chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #dbeafe;
    color: #0369a1;
    font-size: 0.74rem;
    font-weight: 700;
}

.cmr-template-toggle {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cmr-btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
}

.cmr-template-editor-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
}

.cmr-list-head {
    margin-bottom: 16px;
}

.cmr-patient-list {
    display: grid;
    gap: 14px;
}

.cmr-board-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.cmr-source-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.cmr-source-filter {
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.cmr-source-filter:hover,
.cmr-source-filter.active {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 16px 28px -24px rgba(37, 99, 235, 0.5);
}

.cmr-source-filter.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(59, 130, 246, 0.1));
    color: #0f172a;
}

.cmr-board-column {
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(250, 252, 255, 0.98), rgba(255, 255, 255, 0.98));
    min-height: 340px;
    display: grid;
    grid-template-rows: auto 1fr;
}

.cmr-board-column-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.cmr-board-column-head strong {
    color: #0f172a;
}

.cmr-board-column-head span {
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.82rem;
    font-weight: 800;
}

.cmr-board-column-body {
    padding: 14px;
    display: grid;
    align-content: start;
    gap: 12px;
}

.cmr-board-empty {
    min-height: 120px;
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-weight: 700;
}

.cmr-board-card {
    display: grid;
    gap: 10px;
}

.cmr-board-card-body {
    width: 100%;
    padding: 14px;
    border: 1px solid #dbeafe;
    border-radius: 18px;
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.cmr-board-card-body:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 30px -24px rgba(37, 99, 235, 0.45);
    border-color: rgba(56, 189, 248, 0.4);
}

.cmr-board-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cmr-board-card-copy {
    min-width: 0;
}

.cmr-board-card-copy strong {
    display: block;
    color: #0f172a;
}

.cmr-board-card-copy span {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 0.86rem;
}

.cmr-board-card-priority {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    margin-top: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
}

.cmr-board-card-priority.is-danger {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

.cmr-board-card-priority.is-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #a16207;
}

.cmr-board-card-priority.is-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

.cmr-board-card-priority.is-brand {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.cmr-board-card-meta {
    margin-top: 12px;
    display: grid;
    gap: 6px;
}

.cmr-board-card-meta span {
    color: #64748b;
    font-size: 0.82rem;
}

.cmr-board-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cmr-patient-card {
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.cmr-patient-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.95), rgba(37, 99, 235, 0.85));
}

.cmr-patient-main {
    min-width: 0;
}

.cmr-patient-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cmr-patient-identity p {
    margin: 0;
    color: #64748b;
}

.cmr-badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    margin-top: 12px;
}

.cmr-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.cmr-badge.is-danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

.cmr-badge.is-warning {
    background: #fef3c7;
    color: #b45309;
    border-color: #fde68a;
}

.cmr-badge.is-success {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}

.cmr-badge.is-muted,
.cmr-badge.is-neutral {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.cmr-badge.is-brand {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.cmr-patient-priority {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.cmr-patient-priority .material-symbols-outlined {
    font-size: 1rem;
}

.cmr-patient-priority.is-danger {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

.cmr-patient-priority.is-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #a16207;
}

.cmr-patient-priority.is-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

.cmr-patient-priority.is-brand {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.cmr-patient-meta {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-top: 12px;
}

.cmr-patient-meta span {
    padding: 10px 12px;
    border-radius: 14px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.88rem;
}

.cmr-patient-meta strong {
    color: #0f172a;
}

.cmr-patient-actions {
    grid-auto-flow: row;
    align-content: center;
    min-width: 142px;
}

.cmr-btn {
    border: none;
    border-radius: 14px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.cmr-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.cmr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cmr-btn.primary {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: #fff;
    box-shadow: 0 14px 28px -20px rgba(37, 99, 235, 0.9);
}

.cmr-btn.secondary {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.cmr-btn.ghost {
    background: #fff;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.cmr-empty-state {
    padding: 36px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.cmr-empty-state .material-symbols-outlined {
    font-size: 2.2rem;
    color: #0ea5e9;
}

@media (max-width: 1100px) {
    .cmr-hero-top,
    .cmr-hero-board {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .cmr-layout {
        grid-template-columns: 1fr;
    }

    .cmr-composer-card {
        position: static;
    }
}

@media (max-width: 760px) {
    .cmr-shell {
        gap: 16px;
        padding-bottom: 18px;
    }

    .cmr-hero,
    .cmr-composer-card,
    .cmr-list-card,
    .cmr-patient-card {
        padding: 16px;
        border-radius: 16px;
    }

    .cmr-composer-head,
    .cmr-list-head,
    .cmr-preview-head,
    .cmr-patient-head,
    .cmr-hero-top,
    .global-updates-head,
    .global-updates-meta,
    .global-updates-preview-head {
        flex-direction: column;
    }

    .cmr-composer-grid,
    .cmr-selected-meta,
    .cmr-hero-metrics,
    .cmr-board-grid,
    .cmr-patient-card {
        grid-template-columns: 1fr;
    }

    .cmr-source-filters {
        gap: 8px;
    }

    .cmr-inline-actions,
    .cmr-patient-actions {
        grid-auto-flow: row;
    }

    .cmr-composer-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .cmr-template-toggle {
        align-items: stretch;
        flex-direction: column;
    }

    .cmr-selected-tags {
        justify-content: flex-start;
    }

    .global-updates-actions {
        justify-content: stretch;
        flex-direction: column;
    }

    .cmr-badge-row {
        justify-content: flex-start;
    }

    .cmr-patient-actions {
        min-width: 0;
    }
}

@keyframes cmrSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
