/* Dashboard Layout */
html, body {
    max-width: 100vw;
    scroll-behavior: smooth;
}

/* Remove default focus outlines globally */
*:focus {
    outline: none;
}
/* Show subtle custom ring only for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}
/* Remove mobile tap highlight */
* {
    -webkit-tap-highlight-color: transparent;
}

.dashboard-body {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
    margin: 0;
    padding: 0;
    max-width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.sidebar-header .logo {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    font-size: 1rem;
    font-weight: 800;
}

.sidebar-header .logo-img {
    height: 36px;
    width: auto;
    border-radius: 8px;
}

.sidebar-header .brand-name {
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s ease, border-left-color 0.25s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item:active {
    transform: scale(0.98);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), transparent);
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-text {
    font-size: 0.95rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-elev);
    margin-top: auto;
}

.user-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0 1rem;
    text-align: left;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: var(--bg);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: visible;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 200;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

/* Hidden on desktop */
.mobile-sticky-day {
    display: none;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    transition: all 0.3s ease;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
}

/* Agenda Controls */
.agenda-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    position: sticky;
    top: 79px; /* Below dashboard-header */
    z-index: 80;
    background: var(--bg);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.btn-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-nav:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.week-label {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text);
    min-width: 200px;
    text-align: center;
}

.btn-today {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-today:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Agenda Grid */
.agenda-wrapper {
    overflow-x: auto;
    overflow-y: clip;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    position: relative;
    z-index: 1;
}

.agenda-grid {
    min-width: 700px;
    position: relative;
    isolation: isolate;
}

.agenda-header {
    display: grid;
    grid-template-columns: 80px repeat(5, 1fr);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
}

/* Sticky header clone */
.agenda-header-sticky {
    display: none;
    grid-template-columns: 80px repeat(5, 1fr);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
    position: fixed;
    top: 100px; /* Below dashboard-header + controls */
    left: 0;
    right: 0;
    z-index: 90;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.agenda-header-sticky.visible {
    display: grid;
}

.agenda-header-sticky .time-column-header {
    padding: 1rem;
    border-right: 1px solid rgba(255,255,255,0.2);
}

.agenda-header-sticky .day-header {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.2);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.agenda-header-sticky .day-header:last-child {
    border-right: none;
}

.agenda-header-sticky .day-name {
    font-weight: 600;
}

.agenda-header-sticky .day-date {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 400;
}

.time-column-header {
    padding: 1rem;
    border-right: 1px solid rgba(255,255,255,0.2);
}

.day-header {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.2);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    will-change: transform, opacity;
}

.day-name {
    font-weight: 600;
}

.day-date {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 400;
}

.day-header:last-child {
    border-right: none;
}

/* Time Section Divider */
.time-section {
    background: var(--bg);
    padding: 0.75rem 1rem;
    border-top: 2px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.section-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Agenda Rows */
.agenda-row {
    display: grid;
    grid-template-columns: 80px repeat(5, 1fr);
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: visible;
}

.agenda-row:last-child {
    border-bottom: none;
}

.time-cell {
    padding: 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border-right: 1px solid var(--border);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot-cell {
    padding: 0;
    min-height: 80px;
    border-right: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    overflow: visible;
    will-change: transform, opacity;
}

.slot-cell:last-child {
    border-right: none;
}

.slot-cell:hover {
    background: rgba(99, 102, 241, 0.1);
}

.slot-cell.has-appointment {
    background: transparent;
    cursor: default;
    overflow: visible;
    z-index: 2;
}

.slot-cell.spanned-by-appointment {
    background: transparent !important;
    cursor: pointer;
    z-index: 1;
}

.slot-cell.spanned-by-appointment:hover {
    background: transparent !important;
}

.slot-cell.has-appointment:hover,
.slot-cell.has-appointment.is-today-column:hover {
    background: transparent !important;
}

/* Appointment Card in Agenda */
.appointment-card {
    position: absolute;
    left: 2px;
    right: 2px;
    top: 2px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    overflow: hidden;
    z-index: 10;
    border-left: 3px solid var(--primary);
    background: rgba(99, 102, 241, 0.15);
    backdrop-filter: blur(4px);
}

/* Content wrapper that can be repositioned within the card */
.appointment-card .appt-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.4rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: transparent;
    border-radius: 6px;
}

.appointment-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    z-index: 20;
    overflow: visible;
}

.appointment-card .appt-time {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.7rem;
    line-height: 1.2;
}

.appointment-card .appt-patient {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    font-size: 0.8rem;
}

.appointment-card .appt-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.5rem;
    font-size: 0.7rem;
    color: var(--text);
    line-height: 1.2;
}

.appointment-card .appt-center,
.appointment-card .appt-therapist {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    flex-shrink: 0;
}

.appointment-card .appt-sala,
.appointment-card .appt-payment {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

/* Status colors - semi-transparent backgrounds */
.appointment-card.status-pending,
.appointment-card.status-pendiente {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.2);
}

.appointment-card.status-in_progress,
.appointment-card.status-en_progreso {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.2);
}

.appointment-card.status-completed,
.appointment-card.status-finalizada {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.2);
}

.appointment-card.status-cancelled,
.appointment-card.status-anulada {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
    opacity: 0.7;
}

.appointment-card.status-cancelled .appt-patient,
.appointment-card.status-anulada .appt-patient {
    text-decoration: line-through;
}

/* ── Compact cards (single-slot appointments) ── */
.appointment-card.appt-compact .appt-content {
    padding: 0.2rem 0.4rem;
    gap: 1px;
}
.appointment-card.appt-compact .appt-time {
    font-size: 0.65rem;
    line-height: 1.15;
}
.appointment-card.appt-compact .appt-patient {
    font-size: 0.73rem;
    line-height: 1.2;
}
.appointment-card.appt-compact .appt-meta {
    font-size: 0.62rem;
    flex-wrap: wrap;
    overflow: hidden;
    gap: 0.1rem 0.15rem;
    line-height: 1.15;
}
.appointment-card.appt-compact .appt-meta > span {
    flex-shrink: 1;
    min-width: 0;
}

/* Compact card hover */
.appointment-card.appt-compact:hover {
    overflow: visible;
    z-index: 25;
}
.appointment-card.appt-compact:hover .appt-content {
    border-radius: 6px;
}
.appointment-card.appt-compact:hover .appt-meta {
    flex-wrap: wrap;
    overflow: visible;
}

/* ── Spacious cards (multi-slot, 2+ slots) ── */
.appointment-card.appt-spacious {
    overflow: visible;
}
.appointment-card.appt-spacious .appt-content {
    padding: 0.5rem 0.6rem;
    gap: 4px;
}
.appointment-card.appt-spacious .appt-time {
    font-size: 0.75rem;
}
.appointment-card.appt-spacious .appt-patient {
    font-size: 0.85rem;
}
.appointment-card.appt-spacious .appt-meta {
    font-size: 0.75rem;
    gap: 0.3rem 0.6rem;
}

/* Mobile day cards - hidden on desktop */
.mobile-day-card {
    display: none;
}

/* Current Time Indicator */
.current-time-indicator {
    position: absolute;
    left: 80px;
    right: 0;
    height: 2px;
    z-index: 50;
    display: none;
    pointer-events: none;
}

.current-time-indicator.visible {
    display: flex;
    align-items: center;
}

.time-dot {
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    margin-left: -6px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.time-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, #ef4444, transparent);
}

/* Today column highlight */
.day-header.is-today {
    background: rgba(239, 68, 68, 0.2) !important;
    font-weight: 800;
}

.slot-cell.is-today-column {
    background: rgba(239, 68, 68, 0.03);
}

[data-theme="dark"] .slot-cell.is-today-column {
    background: rgba(239, 68, 68, 0.05);
}

.slot-cell.is-today-column:hover {
    background: rgba(99, 102, 241, 0.15);
}

.slot-cell.is-today-column.has-appointment:hover,
.slot-cell.is-today-column.spanned-by-appointment:hover {
    background: transparent !important;
}

/* No-click slots (21:00) */
.slot-cell.no-click,
.mobile-slot.no-click {
    cursor: default;
    pointer-events: none;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(128, 128, 128, 0.05) 5px,
        rgba(128, 128, 128, 0.05) 10px
    );
}

.slot-cell.no-click:hover {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(128, 128, 128, 0.05) 5px,
        rgba(128, 128, 128, 0.05) 10px
    );
}

.agenda-row.last-row .time-cell {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Placeholder Content */
.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    min-height: 400px;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.placeholder-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.placeholder-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 400px;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    .dashboard-body {
        overflow: visible;
    }
    
    .sidebar {
        transform: translateX(-100%);
        height: 100vh;
        height: 100dvh;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: block;
    }

    .sidebar-header {
        padding: 0.75rem 1.25rem;
    }

    .sidebar-header .logo-img {
        height: 32px;
    }

    .sidebar-header .brand-name {
        font-size: 0.95rem;
    }

    .sidebar-nav {
        padding: 0.15rem 0;
        min-height: 0;
        overflow-y: auto;
    }

    .nav-item {
        padding: 0.6rem 1.25rem;
        gap: 0.75rem;
    }

    .sidebar-footer {
        padding: 0.6rem 1.25rem;
    }

    .user-info {
        margin-bottom: 0.5rem;
        gap: 0.4rem;
    }

    .user-avatar {
        width: 34px;
        height: 34px;
        font-size: 0.75rem;
    }

    .logout-btn {
        padding: 0.55rem 0.85rem;
    }

    .sidebar-th-group {
        margin: 0.15rem 0.4rem;
    }

    .sidebar-th-item {
        padding: 0.4rem 0.75rem;
    }

    .sidebar-therapist-list {
        max-height: 30vh;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow: visible;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .dashboard-header {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        width: 100%;
        box-sizing: border-box;
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 200;
    }
    
    .page-title {
        font-size: 1.1rem;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .header-actions {
        gap: 0.5rem;
        flex-shrink: 0;
    }
    
    .header-actions .lang-switch {
        display: none;
    }
    
    .theme-toggle-header {
        padding: 0.2rem;
        gap: 0.15rem;
    }
    
    .theme-toggle-btn {
        padding: 0.3rem 0.4rem;
        font-size: 0.9rem;
    }
    
    .content-area {
        padding: 0.25rem 1rem;
        padding-top: 0;
        overflow: visible;
        width: 100%;
        box-sizing: border-box;
    }
    
    .spa-section {
        width: 100%;
        box-sizing: border-box;
        padding-top: 1rem;
    }
    
    .spa-section[data-section-name="agenda"] {
        padding-top: 0;
    }
    
    .agenda-controls {
        justify-content: center;
        position: -webkit-sticky;
        position: sticky;
        top: 58px;
        z-index: 100;
        background: var(--bg);
        padding: 10px 1rem;
        margin: 0 -1rem;
        margin-bottom: 0.5rem;
        width: calc(100% + 2rem);
        box-sizing: border-box;
    }
    
    .week-label {
        order: -1;
        width: 100%;
        margin-bottom: 0.25rem;
        text-align: center;
    }
    
    .header-actions .lang-switch {
        display: none;
    }
    
    /* Mobile: Stack days vertically */
    .agenda-wrapper {
        overflow: visible;
    }
    
    .agenda-grid {
        min-width: unset;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    .agenda-header {
        display: none;
    }
    
    .agenda-header-sticky {
        display: none !important;
    }
    
    .time-section {
        display: none;
    }
    
    .agenda-row {
        display: none;
    }
    
    /* Mobile day cards */
    .agenda-grid .mobile-day-card {
        display: block;
        background: var(--bg-elev);
        border-radius: 12px;
        border: 1px solid var(--border);
        will-change: transform, opacity;
    }
    
    .mobile-day-header {
        background: linear-gradient(135deg, var(--primary), var(--accent));
        color: white;
        padding: 0.75rem 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: -webkit-sticky;
        position: sticky;
        top: 152px;
        z-index: 90;
        border-radius: 12px 12px 0 0;
        margin: 0 -1px;
        width: calc(100% + 2px);
    }
    
    .mobile-day-header.is-today {
        background: linear-gradient(135deg, #ef4444, #f97316);
    }
    
    /* Mobile Sticky Day Header - hidden since native sticky works */
    .mobile-sticky-day {
        display: none !important;
    }
    
    .mobile-sticky-day.visible {
        display: flex;
    }
    
    .mobile-sticky-day.is-today {
        background: linear-gradient(135deg, #ef4444, #f97316);
    }
    
    .sticky-day-name {
        font-size: 0.95rem;
        text-transform: capitalize;
    }
    
    .sticky-day-date {
        font-size: 0.85rem;
        opacity: 0.9;
    }
    
    .mobile-slot.no-click {
        opacity: 0.5;
        background: repeating-linear-gradient(
            45deg,
            var(--bg),
            var(--bg) 5px,
            rgba(128, 128, 128, 0.1) 5px,
            rgba(128, 128, 128, 0.1) 10px
        );
        cursor: default;
    }
    
    .mobile-day-name {
        font-weight: 700;
        font-size: 1.1rem;
    }
    
    .mobile-day-date {
        font-size: 0.9rem;
        opacity: 0.9;
    }
    
    .mobile-day-slots {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 0.75rem;
        position: relative;
        clip-path: inset(0 0 0 0);
    }
    
    .mobile-slot {
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 6px;
        padding: 0.75rem 1rem;
        text-align: left;
        font-size: 0.9rem;
        color: var(--text-secondary);
        cursor: pointer;
        transition: all 0.2s ease;
        width: 100%;
    }
    
    .mobile-slot:hover {
        background: rgba(99, 102, 241, 0.1);
        border-color: var(--primary);
    }
    
    .mobile-slot.has-appointment:hover {
        background: transparent !important;
        border-color: transparent !important;
    }
    
    .mobile-slot.has-appointment {
        background: transparent;
        border-color: transparent;
        padding: 0;
        min-height: auto;
    }
    
    /* Hide the time label when slot has appointment */
    .mobile-slot.has-appointment::before {
        display: none;
    }
    
    /* Mobile appointment card styling */
    .mobile-appointment.appointment-card {
        position: relative;
        top: auto !important;
        left: auto;
        right: auto;
        height: auto !important;
        margin: 0;
        border-radius: 8px;
        font-size: 0.85rem;
        overflow: hidden;
    }
    
    .mobile-appointment .appt-content {
        position: relative;
        padding: 0.75rem 1rem;
    }
    
    .mobile-appointment .appt-time {
        font-size: 0.8rem;
    }
    
    .mobile-appointment .appt-patient {
        font-size: 0.9rem;
    }
    
    .mobile-appointment .appt-meta {
        font-size: 0.75rem;
    }
    
    .current-time-indicator {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 1rem;
    }
    
    .agenda-controls {
        gap: 0.5rem;
    }
    
    .btn-nav, .btn-today {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* ============================================
   MODALES
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease, backdrop-filter 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal {
    background: var(--bg-elev);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.92) translateY(30px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal.modal-lg {
    max-width: 700px;
}

.modal.modal-md {
    max-width: 550px;
}

/* Report columns grid */
.report-columns-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* Month selector */
.month-selector {
    display: flex;
    gap: 0.5rem;
}

.month-selector select:first-child {
    flex: 2;
}

.month-selector select:last-child {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"]:checked + span {
    color: var(--primary);
    font-weight: 500;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Form Styles in Modal */

/* Blur effect on cita fields until patient is selected */
#cita-patient-wrapper {
    transition: filter 0.4s ease, opacity 0.4s ease;
}

#cita-patient-wrapper.cita-fields-blurred {
    filter: blur(3px);
    opacity: 0.45;
    pointer-events: none;
    user-select: none;
}

#cita-fields-below-patient {
    transition: filter 0.4s ease, opacity 0.4s ease;
    margin-top: 0.5rem;
}

#cita-fields-below-patient.cita-fields-blurred {
    filter: blur(3px);
    opacity: 0.45;
    pointer-events: none;
    user-select: none;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.form-label .label-hint {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.form-label .required {
    color: #ef4444;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.7;
    border-style: dashed;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Patient Search Dropdown */
.patient-search-container {
    position: relative;
    width: 100%;
}

.patient-search-input {
    width: 100%;
    padding-right: 2.5rem;
}

.patient-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-elev);
    border: 2px solid var(--border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.patient-dropdown.open {
    display: block;
}

.patient-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

.patient-dropdown-item:last-child {
    border-bottom: none;
}

.patient-dropdown-item:hover,
.patient-dropdown-item.selected {
    background: var(--primary);
    color: white;
}

.patient-dropdown-item:hover .patient-added-date,
.patient-dropdown-item.selected .patient-added-date {
    color: rgba(255,255,255,0.8);
}

.patient-name {
    font-weight: 500;
}

.patient-added-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.patient-dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row > .form-group {
    margin-bottom: 0;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0) scale(0.97);
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-secondary:active {
    transform: scale(0.97);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-danger:active {
    transform: translateY(0) scale(0.97);
    box-shadow: none;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    transition: transform 0.15s ease, background 0.2s ease;
}

.btn-icon:active {
    transform: scale(0.9);
}

/* Small action buttons (contacts, etc.) */
.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-sm:active {
    transform: scale(0.95);
}

.btn-edit {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.btn-edit:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
}

.btn-danger-outline {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
}

.btn-report-outline {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-report-outline:hover {
    background: rgba(16, 185, 129, 0.18);
    border-color: #10b981;
}

/* Cards List */
.cards-list {
    display: grid;
    gap: 1rem;
}

.card-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.card-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.card-content {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Top Actions Bar */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-elev);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
    flex: 1;
    max-width: 300px;
}

.search-box input {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    flex: 1;
    outline: none;
}

.search-box .search-icon {
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Settings Styles */
.settings-section {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.settings-row:first-child {
    padding-top: 0;
}

.settings-label {
    font-weight: 500;
    color: var(--text);
}

.settings-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.settings-control {
    flex-shrink: 0;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.toggle-option {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.toggle-option.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

/* Centro Logo Upload */
.logo-upload {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-preview {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: var(--bg);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-preview-empty {
    font-size: 2rem;
    color: var(--text-secondary);
}

.logo-upload-btn {
    flex: 1;
}

/* Logo Crop Modal */
.crop-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.crop-image-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 400px;
    overflow: hidden;
    background: #1a1a1a;
    border-radius: 8px;
}

.crop-image-wrapper img {
    max-width: 100%;
    max-height: 400px;
    display: block;
    opacity: 0.5;
}

.crop-selection {
    position: absolute;
    border: 3px solid #fff;
    background: rgba(255, 255, 255, 0.1);
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 10px rgba(0, 0, 0, 0.5);
}

.crop-selection::before,
.crop-selection::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 2px;
}

.crop-selection::before {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.crop-selection::after {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

/* Cita Status Badge */
.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pendiente {
    background: rgba(251, 191, 36, 0.2);
    color: #f59e0b;
}

.status-en_proceso {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.status-finalizada {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.status-anulada {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Appointment in Calendar */
.slot-appointment {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.slot-appointment:hover {
    transform: scale(1.02);
}

/* Contact Card */
.contacts-group-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.4rem 0.25rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.contacts-group-count {
    font-size: 0.72rem;
    background: var(--surface);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-weight: 500;
}

.contact-card,
.centro-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.contact-card:hover,
.centro-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.contact-avatar,
.centro-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.centro-logo {
    border-radius: 12px;
    font-size: 1.5rem;
}

.contact-avatar img,
.centro-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.contact-info,
.centro-info {
    flex: 1;
    min-width: 0;
}

.contact-name,
.centro-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-details,
.centro-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.contact-details span,
.centro-details span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.contact-actions,
.centro-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Sala chips inside centro cards */
.centro-salas-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.sala-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-secondary);
    white-space: nowrap;
}

.sala-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Current time line in agenda */
.current-time-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #ef4444 0%, #ef4444 50%, transparent 100%);
    z-index: 20;
    pointer-events: none;
}

.current-time-line::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.current-time-line::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #ef4444 0%, rgba(239, 68, 68, 0.5) 30%, rgba(239, 68, 68, 0.2) 60%, transparent 100%);
}

/* Pulse animation only when passing through an in-progress appointment */
.current-time-line.has-active-appointment::before {
    animation: pulse-time 3s ease-in-out infinite;
}

@keyframes pulse-time {
    0%, 100% { 
        box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
        transform: translateY(-50%) scale(1);
    }
    50% { 
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.7), 0 0 20px rgba(239, 68, 68, 0.3);
        transform: translateY(-50%) scale(1.15);
    }
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal,
    .modal.modal-lg,
    .modal.modal-md {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        height: 100%;
        width: 100%;
    }
    
    /* Small confirm/alert modals should NOT be fullscreen */
    .modal[style*="max-width: 400px"],
    .modal.modal-compact {
        height: auto;
        max-height: 80vh;
        border-radius: 16px;
        margin: auto 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .modal-overlay {
        padding: 0;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .contact-card,
    .centro-card {
        flex-wrap: wrap;
    }
    
    .contact-actions,
    .centro-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
    }
    
    .settings-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-tab:hover {
    background: var(--bg);
    color: var(--text);
}

.settings-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.settings-panels {
    position: relative;
}

.settings-panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

.settings-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Settings Sections */
.settings-section {
    background: var(--bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.settings-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile settings tabs */
@media (max-width: 600px) {
    .settings-tabs {
        flex-wrap: wrap;
    }
    
    .settings-tab {
        flex: 1;
        min-width: 120px;
        justify-content: center;
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* Subscription Card */
.subscription-card {
    background: linear-gradient(135deg, var(--bg-elev) 0%, var(--bg) 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
}

.subscription-loading {
    text-align: center;
    color: var(--muted);
    padding: 2rem;
}

.subscription-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.subscription-plan {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.subscription-plan-icon {
    font-size: 2.5rem;
}

.subscription-plan-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.subscription-plan-price {
    font-size: 1.1rem;
    color: var(--muted);
}

.subscription-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.subscription-status.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.subscription-status.expired {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.subscription-status.none {
    background: rgba(100, 116, 139, 0.15);
    color: var(--muted);
}

.subscription-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: 12px;
}

.subscription-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.subscription-detail-label {
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subscription-detail-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.subscription-detail-value.warning {
    color: #f59e0b;
}

.subscription-detail-value.danger {
    color: #ef4444;
}

.subscription-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.subscription-actions .btn {
    flex: 1;
    min-width: 180px;
}

.subscription-no-plan {
    text-align: center;
    padding: 2rem;
}

.subscription-no-plan h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.subscription-no-plan p {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.subscription-auto-renew {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: 8px;
    margin-top: 1rem;
}

.subscription-auto-renew-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subscription-auto-renew-status.active {
    color: var(--success);
}

.subscription-auto-renew-status.inactive {
    color: var(--muted);
}

/* Center-managed subscription notice */
.subscription-managed-notice {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: var(--bg-hover, rgba(99, 102, 241, 0.08));
    border: 1px solid var(--primary, #6366f1);
    border-radius: 12px;
}
.subscription-managed-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    line-height: 1.2;
}
.subscription-managed-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.subscription-managed-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.subscription-managed-footer {
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

/* ===========================================
   STATISTICS PAGE v2
   =========================================== */

.stats-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 0;
    max-width: 1400px;
    margin: 0 auto;
}

/* Toolbar: mode toggle + nav + export */
.stats-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.stats-mode-toggle {
    display: flex;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.stats-mode-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.stats-mode-btn:hover {
    color: var(--text);
    background: rgba(99, 102, 241, 0.08);
}

.stats-mode-btn.active {
    background: var(--primary);
    color: #fff;
}

.stats-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stats-period-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    min-width: 180px;
    text-align: center;
}

.btn-month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-month-nav:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-export-report {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elev);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export-report:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* KPIs Grid */
.stats-kpis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stats-center-kpis {
    grid-template-columns: repeat(2, 1fr);
}

.kpi-card {
    background: var(--bg-elev);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent, #8b5cf6));
    opacity: 0;
    transition: opacity 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-card.kpi-highlight {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.06));
    border-color: rgba(99, 102, 241, 0.2);
}

.kpi-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon {
    font-size: 1.5rem;
}

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.kpi-sub {
    margin-top: 0.15rem;
}

.kpi-sub-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.kpi-diff {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
}

.kpi-diff.positive {
    color: #059669;
    background: rgba(16, 185, 129, 0.12);
}

.kpi-diff.negative {
    color: #dc2626;
    background: rgba(239, 68, 68, 0.12);
}

.kpi-diff.neutral {
    color: var(--text-secondary);
    background: rgba(107, 114, 128, 0.1);
}

/* --- Center KPI Ranking Cards --- */
.kpi-ranking-card {
    grid-column: span 1;
}

.kpi-ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.kpi-ranking-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
}

.kpi-ranking-pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    background: rgba(107, 114, 128, 0.12);
    color: var(--text-secondary);
}

.kpi-ranking-pos.pos-1 {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}

.kpi-ranking-pos.pos-2 {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: #fff;
}

.kpi-ranking-pos.pos-3 {
    background: linear-gradient(135deg, #c2956a, #a67c52);
    color: #fff;
}

.kpi-ranking-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kpi-ranking-count {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.kpi-ranking-empty {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 0.5rem 0;
}

/* Charts Grid */
.stats-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.chart-card {
    background: var(--bg-elev);
    border-radius: 14px;
    padding: 1.25rem;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s;
}

.chart-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.chart-card.chart-wide {
    grid-column: span 1;
}

.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

.chart-container-sm {
    height: 260px;
}

/* Third row: 3 equal charts */
.stats-charts-grid .chart-card:nth-child(3),
.stats-charts-grid .chart-card:nth-child(4),
.stats-charts-grid .chart-card:nth-child(5) {
    grid-column: span 1;
}

/* When we have 3 items in a row, use 3 cols for them */
@supports (grid-template-columns: repeat(3, 1fr)) {
    .stats-charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Stats Footer */
.stats-footer {
    display: flex;
    justify-content: center;
    padding-top: 0.5rem;
}

.stats-update-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* Export Modal */
.export-modal-content {
    max-width: 520px;
    width: 95%;
}

.export-field {
    margin-bottom: 1rem;
}

.export-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.export-columns {
    margin-top: 1rem;
}

.export-columns > label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.export-column-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.export-col-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.82rem;
    user-select: none;
}

.export-col-item:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.export-col-item input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Stats Responsive - Tablet */
@media (max-width: 1024px) {
    .stats-kpis {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
    .stats-charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Stats Responsive - Mobile */
@media (max-width: 768px) {
    .stats-container {
        gap: 1rem;
    }
    .stats-toolbar {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }
    .stats-mode-toggle {
        justify-content: center;
        width: auto;
    }
    .stats-mode-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
    .stats-nav {
        justify-content: center;
    }
    .btn-export-report {
        align-self: center;
    }
    .stats-period-title {
        font-size: 1.15rem;
        min-width: 140px;
    }
    .stats-kpis {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }
    .stats-center-kpis {
        grid-template-columns: 1fr;
    }
    .kpi-card {
        padding: 1rem;
    }
    .kpi-icon-wrap {
        width: 40px;
        height: 40px;
    }
    .kpi-icon {
        font-size: 1.2rem;
    }
    .kpi-value {
        font-size: 1.3rem;
    }
    .stats-charts-grid {
        grid-template-columns: 1fr;
    }
    .chart-container {
        height: 260px;
    }
    .export-column-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-kpis {
        grid-template-columns: 1fr;
    }
    .kpi-card {
        flex-direction: row;
        text-align: left;
    }
    .chart-container,
    .chart-container-sm {
        height: 220px;
    }
    .stats-period-title {
        font-size: 1rem;
        min-width: 120px;
    }
}

/* ========================================
   SPA Sections & Transitions
======================================== */
.spa-section {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.spa-section.active {
    display: block;
}

.spa-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.spa-section.exiting {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* Fade slide transition */
.spa-section.fade-enter {
    opacity: 0;
    transform: translateY(30px);
}

.spa-section.fade-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.35s ease-out, transform 0.35s ease-out;
}

.spa-section.fade-exit {
    opacity: 1;
    transform: translateY(0);
}

.spa-section.fade-exit-active {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.25s ease-in, transform 0.25s ease-in;
}

/* Nav link active transition */
.nav-link {
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.nav-link.active::before {
    transform: scaleY(1);
}

/* SPA loading indicator */
.spa-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    z-index: 9999;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.spa-loading.active {
    transform: scaleX(1);
}

/* ============================================
   CENTER MANAGEMENT - Therapists
   ============================================ */

/* Therapist count badge */
.therapists-count {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Therapist card in list */
.therapist-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.therapist-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.therapist-card .card-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    flex: 1;
}

.therapist-avatar {
    width: 44px;
    height: 44px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.therapist-card .card-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.therapist-card .card-info strong {
    font-size: 1rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.therapist-card .card-info .text-muted {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Therapist detail panel */
.therapist-detail-panel {
    animation: fadeIn 0.2s ease;
}

.therapist-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.therapist-detail-info h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

/* Therapist tabs */
.therapist-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.therapist-tab {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.therapist-tab:hover {
    color: var(--text);
}

.therapist-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Therapist agenda grid (read-only, reuses .agenda-grid styles) */
.th-agenda-wrapper {
    border-radius: 12px;
    border: 1px solid var(--border);
}

.th-agenda-grid .slot-cell {
    cursor: default;
    position: relative;
}

.th-agenda-grid .slot-cell:hover {
    background: inherit;
}

/* Therapist contacts list */
.th-contacts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.th-contacts-count {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

.th-contact-card-full {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    transition: border-color 0.2s;
}

.th-contact-card-full:hover {
    border-color: var(--primary);
}

.th-contacts-group-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.35rem 0.25rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.th-contacts-group-count {
    font-size: 0.7rem;
    background: var(--surface);
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-weight: 500;
}

/* Therapist stats grid */
.th-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.th-stat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.th-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.th-stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Therapist stats enhanced */
.th-stats-period {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    padding: 0 0.25rem;
}

.th-diff {
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.th-diff.positive { color: var(--success, #10b981); }
.th-diff.negative { color: var(--danger, #ef4444); }
.th-diff.neutral  { color: var(--text-secondary); }

.th-stats-section {
    margin-top: 1.25rem;
    padding: 0 0.25rem;
}
.th-stats-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.th-stat-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
}
.th-breakdown-item {
    font-size: 0.85rem;
    color: var(--text);
}

.th-mini-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 80px;
    padding: 0 0.25rem;
}
.th-mini-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.th-mini-bar {
    width: 100%;
    max-width: 32px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
}
.th-mini-bar-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 3px;
}
.th-mini-bar-val {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    order: -1;
}

/* Therapist agenda controls */
.th-agenda-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    position: sticky;
    top: 79px;
    z-index: 80;
    background: var(--bg);
    padding: 0.5rem 0;
}

/* Sticky header clone – therapist agenda */
.th-agenda-header-sticky {
    display: none;
    grid-template-columns: 80px repeat(5, 1fr);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
    position: fixed;
    top: 100px;
    left: 0;
    right: 0;
    z-index: 90;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.th-agenda-header-sticky.visible {
    display: grid;
}

.th-agenda-header-sticky .time-column-header {
    padding: 1rem;
    border-right: 1px solid rgba(255,255,255,0.2);
}

.th-agenda-header-sticky .day-header {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.2);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.th-agenda-header-sticky .day-header:last-child {
    border-right: none;
}

.th-agenda-header-sticky .day-name {
    font-weight: 600;
}

.th-agenda-header-sticky .day-date {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 400;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-active, .badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-default {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

/* Alerts */
.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

/* ============================================
   CENTER-BOUND THERAPIST VIEW (Centros section)
   ============================================ */
.center-bound-card {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.center-bound-logo {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    background: var(--bg);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.center-bound-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.center-bound-logo-placeholder {
    font-size: 3rem;
}

.center-bound-info h2 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.center-bound-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
}

.center-bound-notice .notice-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.center-bound-notice p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
}

@media (max-width: 768px) {
    .therapist-card {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .therapist-card .card-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .therapist-tabs {
        overflow-x: auto;
    }
    
    .center-bound-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    /* ─── Center therapist agenda: mobile layout (same as autonomous) ─── */
    .th-agenda-wrapper {
        max-height: none;
        overflow: visible;
        border: none;
    }

    .th-agenda-grid {
        min-width: unset;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .th-agenda-grid .agenda-header,
    .th-agenda-grid .time-section,
    .th-agenda-grid .agenda-row {
        display: none;
    }

    .th-agenda-grid .mobile-day-card {
        display: block;
        background: var(--bg-elev);
        border-radius: 12px;
        border: 1px solid var(--border);
    }

    .th-agenda-grid .mobile-slot {
        cursor: pointer;
    }

    .th-agenda-grid .mobile-slot.has-appointment {
        pointer-events: auto;
        cursor: default;
    }

    .th-agenda-controls {
        justify-content: center;
        position: -webkit-sticky;
        position: sticky;
        top: 58px;
        z-index: 100;
        background: var(--bg);
        padding: 10px 1rem;
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
        box-sizing: border-box;
    }

    .th-agenda-header-sticky {
        display: none !important;
    }

    /* Center agenda mobile-day-header: adjusted for center toolbar height */
    #section-center-agenda .mobile-day-header {
        top: 158px;
    }
    .th-agenda-grid .mobile-day-header {
        top: 110px;
    }
}

/* ─── Sidebar Therapist List (center accounts) ─── */
.sidebar-th-group {
    margin: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(99,102,241,0.04);
    overflow: hidden;
}

.sidebar-th-group .sidebar-th-toggle {
    margin: 0;
    border-radius: 0;
}

.sidebar-th-toggle {
    user-select: none;
}

.sidebar-th-chevron {
    margin-left: 0.25rem;
    transition: transform 0.25s ease;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-th-chevron.collapsed {
    transform: rotate(-90deg);
}

.sidebar-therapist-list {
    padding: 0 0.35rem 0.35rem;
    max-height: 50vh;
    overflow-y: auto;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
}

.sidebar-therapist-list.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.sidebar-th-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
}

.sidebar-th-item:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar-th-item.active {
    color: var(--text);
    font-weight: 600;
    filter: brightness(1.05);
}

.sidebar-th-item .th-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #ef4444;
    transition: background 0.3s ease;
}

.sidebar-th-item .th-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.sidebar-th-item .th-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-th-add {
    opacity: 0.8;
    margin-top: 4px;
    justify-content: center;
    border: 1px dashed var(--border);
    background: transparent !important;
}

.sidebar-th-add:hover {
    opacity: 1;
    border-color: var(--primary);
    background: rgba(99,102,241,0.08) !important;
}

.sidebar-th-add .th-name {
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════ */
/*  SALAS (ROOMS) SECTION                                */
/* ═══════════════════════════════════════════════════════ */
/* Centro modal - inline sala items */
.centro-salas-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.centro-sala-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.88rem;
}

.centro-sala-item .btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
}

.salas-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.sala-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.sala-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.sala-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.sala-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sala-name {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sala-card-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.sala-card-actions .btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
}

/* ═══════════════════════════════════════════════════════ */
/*  COLOR WHEEL (Custom HSL wheel for therapist & sala)    */
/* ═══════════════════════════════════════════════════════ */
.color-wheel-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.color-wheel-canvas {
    cursor: crosshair;
    border-radius: 50%;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    transition: box-shadow 0.2s;
}

.color-wheel-canvas:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}

.color-wheel-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-wheel-selected {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════ */
/*  THERAPIST COLOR: FULL BG IN SIDEBAR                   */
/* ═══════════════════════════════════════════════════════ */
.sidebar-th-item[style*="background"] {
    border-left: 3px solid transparent;
    transition: all 0.15s ease, background 0.3s ease;
}

.sidebar-th-item.active[style*="background"] {
    filter: brightness(1.05);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════ */
/*  THERAPIST SETTINGS TAB (COLOR PICKER)                 */
/* ═══════════════════════════════════════════════════════ */
.th-settings-compact {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.th-settings-col {
    flex: 1;
    min-width: 0;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.th-settings-label {
    margin: 0 0 0.6rem;
    font-size: 0.92rem;
    font-weight: 700;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.th-color-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.th-color-compact .color-wheel-canvas {
    width: 110px;
    height: 110px;
}

.th-color-preview {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.78rem;
    min-width: 80px;
    transition: all 0.2s;
}

/* Commission radios */
.th-comision-radios {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.th-comision-radio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all 0.15s ease;
}

.th-comision-radio:hover {
    border-color: var(--primary);
    background: rgba(99,102,241,0.06);
}

.th-comision-radio:has(input:checked) {
    border-color: var(--primary);
    background: rgba(99,102,241,0.1);
    color: var(--text);
    font-weight: 500;
}

.th-comision-radio input[type="radio"] {
    accent-color: var(--primary);
    margin: 0;
    width: 14px;
    height: 14px;
}

.th-comision-radio span {
    user-select: none;
}

.th-comision-valor-inline {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
}

.th-comision-valor-inline .form-input {
    padding: 0.25rem 0.4rem;
    font-size: 0.82rem;
}

.th-comision-valor-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.th-comision-suffix {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.th-comision-preview {
    padding: 0.4rem 0.6rem;
    background: var(--surface);
    border-radius: var(--radius);
    font-size: 0.78rem;
    border-left: 3px solid var(--primary);
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .th-settings-compact {
        flex-direction: column;
    }
    .th-color-compact .color-wheel-canvas {
        width: 100px;
        height: 100px;
    }
}

/* ═══════════════════════════════════════════════════════ */
/*  CENTER AGENDA (BY ROOM)                               */
/* ═══════════════════════════════════════════════════════ */
.center-agenda-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    position: sticky;
    top: 79px;
    z-index: 80;
    background: var(--bg);
    padding: 0.5rem 0;
}

/* Sticky header clone – center agenda */
.ca-agenda-header-sticky {
    display: none;
    grid-template-columns: 80px repeat(5, 1fr);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-weight: 600;
    position: fixed;
    top: 100px;
    left: 0;
    right: 0;
    z-index: 90;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.ca-agenda-header-sticky.visible {
    display: grid;
}

.ca-agenda-header-sticky .time-column-header {
    padding: 1rem;
    border-right: 1px solid rgba(255,255,255,0.2);
}

.ca-agenda-header-sticky .day-header {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.2);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ca-agenda-header-sticky .day-header:last-child {
    border-right: none;
}

.ca-agenda-header-sticky .day-name {
    font-weight: 600;
}

.ca-agenda-header-sticky .day-date {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 400;
}

.room-selector-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.room-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.3rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elev, var(--bg));
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    color: var(--text-secondary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-transform: none;
    letter-spacing: 0.01em;
    min-height: 42px;
}

.room-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 3px 8px rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

.room-tab:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.room-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
}

.room-tab.active:hover {
    background: var(--primary);
    filter: brightness(1.1);
}

.room-tab-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.room-tab.active .room-tab-dot {
    background: #fff !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.center-agenda-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Center agenda appointment cards */
.ca-appt-card .appt-therapist {
    font-weight: 600;
    font-size: 0.78rem;
}

.ca-appt-card .appt-sala {
    font-size: 0.75rem;
    opacity: 0.75;
}

/* ═══════════════════════════════════════════════════════ */
/*  ROOM SELECTOR IN CITA MODAL                           */
/* ═══════════════════════════════════════════════════════ */
#cita-sala option[style*="color: #ef4444"] {
    font-weight: 600;
}

#cita-sala option[style*="color: #22c55e"] {
    font-weight: 500;
}

#cita-sala-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* ═══════════════════════════════════════════════════════ */
/*  RESPONSIVE: SALAS + CENTER AGENDA                     */
/* ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .salas-grid {
        grid-template-columns: 1fr;
    }

    .center-agenda-toolbar {
        flex-direction: column;
        align-items: stretch;
        position: -webkit-sticky;
        position: sticky;
        top: 58px;
        z-index: 100;
        background: var(--bg);
        padding: 0.5rem 0;
    }

    .ca-agenda-header-sticky {
        display: none !important;
    }

    .room-selector-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
        flex-wrap: nowrap;
    }

    .center-agenda-nav {
        justify-content: center;
        flex-wrap: wrap;
    }

    .center-agenda-nav .week-label {
        order: -1;
        width: 100%;
        text-align: center;
        min-width: 0;
        margin-bottom: 0.25rem;
    }

    /* Show mobile day cards, hide desktop grid in center agenda */
    #ca-agenda-header,
    #ca-morning-rows,
    #ca-afternoon-rows,
    #section-center-agenda .time-section {
        display: none;
    }

    #ca-mobile-days {
        display: block;
    }

    .color-wheel-canvas {
        width: 140px;
        height: 140px;
    }
}

@media (min-width: 769px) {
    #ca-mobile-days {
        display: none;
    }
}

/* --- Salas hint arrow animation --- */
.salas-hint-bounce {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    animation: salasHintBounce 0.5s ease infinite alternate;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}
.salas-hint-arrow-icon {
    font-size: 1.3rem;
    animation: salasArrowPulse 0.5s ease infinite alternate;
}
@keyframes salasHintBounce {
    from { transform: translateY(0); }
    to { transform: translateY(-4px); }
}
@keyframes salasArrowPulse {
    from { transform: scale(1); }
    to { transform: scale(1.25); }
}
.salas-hint-fadeout {
    animation: salasHintFade 0.5s ease forwards;
}
@keyframes salasHintFade {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ============================================
   BILLING / FACTURAS
   ============================================ */

/* Invoice cards list */
.factura-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elev, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.65rem;
    transition: box-shadow 0.18s, border-color 0.18s;
    cursor: pointer;
}
.factura-card:hover {
    border-color: var(--primary, #6366f1);
    box-shadow: 0 2px 12px rgba(99,102,241,0.10);
}
.factura-card-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.factura-card-number {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text, #1e1e1e);
}
.factura-card-recipient {
    font-size: 0.88rem;
    color: var(--muted, #6b7280);
}
.factura-card-date {
    font-size: 0.78rem;
    color: var(--muted, #9ca3af);
}
.factura-card-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.factura-card-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text, #1e1e1e);
    min-width: 75px;
    text-align: right;
}
.factura-card-actions {
    display: flex;
    gap: 0.35rem;
}
.factura-card-actions .btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
    background: var(--bg-elev, #fff);
    color: var(--text, #1e1e1e);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.factura-card-actions .btn-sm:hover {
    border-color: var(--primary, #6366f1);
    color: var(--primary, #6366f1);
    background: rgba(99, 102, 241, 0.06);
}
.factura-card-actions .btn-outline-danger:hover {
    border-color: var(--danger, #ef4444);
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.06);
}
.factura-card-actions .btn-sm.btn-pdf {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
    border-color: #2563eb;
    font-weight: 600;
}
.factura-card-actions .btn-sm.btn-pdf:hover {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    border-color: #1d4ed8;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.factura-card-actions .btn-sm.btn-verifactu {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    border-color: #059669;
    font-weight: 600;
}
.factura-card-actions .btn-sm.btn-verifactu:hover {
    background: linear-gradient(135deg, #047857, #059669);
    border-color: #047857;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}


/* Status badges */
.factura-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    white-space: nowrap;
}
.badge-draft {
    background: #fef3c7;
    color: #92400e;
}
.badge-issued {
    background: #dbeafe;
    color: #1e40af;
}
.badge-paid {
    background: #d1fae5;
    color: #065f46;
}
.badge-voided {
    background: #fee2e2;
    color: #991b1b;
}

/* Modal large */
.modal-lg {
    max-width: 720px;
    width: 95vw;
}

/* Form row helpers */
.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}
.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

/* Invoice line items */
.factura-lineas-section {
    margin-top: 0.5rem;
}
.factura-lineas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.factura-linea {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    margin-bottom: 0.4rem;
    transition: border-color 0.15s;
}
.factura-linea:hover {
    border-color: var(--primary, #6366f1);
}
.factura-linea-main {
    display: flex;
}
.factura-linea-main .form-input {
    flex: 1;
    font-size: 0.88rem;
}
.factura-linea-nums {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.factura-linea-nums .form-input {
    width: 72px;
    min-width: 55px;
    font-size: 0.82rem;
    text-align: right;
    padding: 0.3rem 0.4rem;
}
.factura-linea-nums select.form-input {
    width: 78px;
    min-width: 60px;
    text-align: center;
    cursor: pointer;
    appearance: auto;
}
.factura-linea-nums .fl-concepto {
    flex: 1;
    text-align: left;
}
.fl-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    align-items: center;
}
.fl-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1;
}
.fl-input-euro {
    position: relative;
    display: flex;
    align-items: center;
}
.fl-input-euro .form-input {
    padding-right: 1.4rem;
}
.fl-euro-symbol {
    position: absolute;
    right: 0.35rem;
    font-size: 0.82rem;
    color: var(--muted, #64748b);
    pointer-events: none;
    font-weight: 600;
}
.fl-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--danger, #ef4444);
    padding: 0.2rem;
    border-radius: 4px;
    transition: background 0.15s;
}
.fl-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Invoice totals */
.factura-totals {
    margin-top: 0.75rem;
    border-top: 2px solid var(--border-color, #e5e7eb);
    padding-top: 0.5rem;
    max-width: 300px;
    margin-left: auto;
}
.factura-total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.88rem;
    color: var(--text-secondary, #6b7280);
}
.factura-total-final {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary, #6366f1);
    border-top: 2px solid var(--primary, #6366f1);
    padding-top: 0.4rem;
    margin-top: 0.25rem;
}

/* Responsive */
@media (max-width: 640px) {
    .form-row-3 { grid-template-columns: 1fr; }
    .form-row-4 { grid-template-columns: repeat(2, 1fr); }
    .factura-card { flex-direction: column; align-items: flex-start; gap: 0.65rem; position: relative; padding-top: 2.2rem; }
    .factura-card-right { width: 100%; justify-content: space-between; flex-wrap: wrap; }
    .factura-card .factura-badge { position: absolute; top: 0.6rem; right: 0.75rem; }
    .factura-card-actions { width: 100%; }
    .factura-card-actions .btn-sm { flex: 1; justify-content: center; font-size: 0.72rem; padding: 0.25rem 0.4rem; }
    .factura-linea-nums { flex-wrap: wrap; }
    .factura-linea-nums .form-input { width: 60px; }
    .factura-linea-nums select.form-input { width: 68px; }
    .fl-field-group { min-width: 55px; }
}

/* Searchable recipient dropdown */
.factura-dest-wrapper {
    position: relative;
}
.factura-dest-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elev);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    max-height: 280px;
    overflow: hidden;
    z-index: 100;
    box-shadow: var(--shadow);
    margin-top: 2px;
}
.factura-dest-dropdown .dest-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
    max-height: 280px;
}
.factura-dest-dropdown .dest-panel {
    overflow-y: auto;
    max-height: 280px;
    padding-bottom: 0.25rem;
}
.factura-dest-dropdown .dest-panel-left {
    border-right: 1px solid var(--border, #e2e8f0);
}
@media (max-width: 520px) {
    .factura-dest-dropdown .dest-panels {
        grid-template-columns: 1fr 1fr;
        max-height: 300px;
    }
    .factura-dest-dropdown .dest-panel {
        max-height: 300px;
    }
    .factura-dest-dropdown {
        max-height: 300px;
    }
    .factura-dest-dropdown .dest-option {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
        gap: 0.3rem;
    }
    .factura-dest-dropdown .dest-option .dest-type-badge {
        display: none;
    }
    .factura-dest-dropdown .dest-group-label {
        font-size: 0.68rem;
        padding: 0.4rem 0.5rem 0.2rem;
    }
}
.factura-dest-dropdown.open {
    display: block;
}
.factura-dest-dropdown .dest-group-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted, #64748b);
    padding: 0.5rem 0.75rem 0.25rem;
}
.factura-dest-dropdown .dest-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text, #0f172a);
    transition: background 0.12s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
}
.factura-dest-dropdown .dest-option .dest-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.factura-dest-dropdown .dest-option:hover,
.factura-dest-dropdown .dest-option.highlighted {
    background: var(--primary, #6366f1);
    color: #fff;
}
.factura-dest-dropdown .dest-option .dest-type-badge {
    font-size: 0.68rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}
.dest-type-badge.badge-paciente {
    background: #dbeafe;
    color: #1e40af;
}
.dest-type-badge.badge-centro {
    background: #fef3c7;
    color: #92400e;
}
.dest-type-badge.badge-terapeuta {
    background: #d1fae5;
    color: #065f46;
}

/* ======================================
   Plan Usage Bar
   ====================================== */
.plan-usage-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.plan-usage-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    white-space: nowrap;
}
.plan-usage-label {
    color: var(--text-secondary);
}
.plan-usage-count {
    font-weight: 600;
    color: var(--text);
}
.plan-usage-track {
    flex: 1;
    min-width: 80px;
    height: 8px;
    background: var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.plan-usage-fill {
    height: 100%;
    border-radius: 8px;
    background: var(--primary);
    transition: width 0.4s ease;
}
.plan-usage-fill.warning {
    background: #f59e0b;
}
.plan-usage-fill.danger {
    background: #ef4444;
}
.btn-upgrade {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.btn-upgrade:hover {
    opacity: 0.85;
}

/* Upgrade modal */
.upgrade-plan-icon {
    text-align: center;
    font-size: 3rem;
    margin-bottom: 0.5rem;
}
#upgrade-plan-message {
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.upgrade-plan-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
}
.upgrade-plan-card {
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid var(--border);
    text-align: center;
}
.upgrade-plan-card.current {
    opacity: 0.6;
}
.upgrade-plan-card.recommended {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.upgrade-plan-card h4 {
    margin: 0 0 0.3rem;
    font-size: 1rem;
}
.upgrade-plan-card .plan-price {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}
.upgrade-plan-card .plan-price small {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
}
.upgrade-plan-card ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    text-align: left;
}
.upgrade-plan-card ul li {
    padding: 0.15rem 0;
}
.upgrade-plan-card ul li::before {
    content: "✓ ";
    color: #22c55e;
    font-weight: 700;
}

