/* ============================================================
   SISTEMA DE GESTIÓN — app.css
   Modern Clinical UI — Variables + Layout + Componentes
   ============================================================ */

/* --- RESET & BASE --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:     #1B6B50;
    --color-primary-50:  color-mix(in srgb, var(--color-primary) 8%, #fff);
    --color-primary-100: color-mix(in srgb, var(--color-primary) 15%, #fff);
    --color-primary-200: color-mix(in srgb, var(--color-primary) 25%, #fff);
    --color-primary-600: color-mix(in srgb, var(--color-primary) 85%, #000);
    --color-primary-700: color-mix(in srgb, var(--color-primary) 75%, #000);
    --color-primary-800: color-mix(in srgb, var(--color-primary) 60%, #000);
    --color-primary-900: color-mix(in srgb, var(--color-primary) 50%, #000);
    --color-secondary:   #10B981;
    --color-accent:      #C9A84C;
    --color-accent-50:   #FFFBEB;
    --color-danger:      #EF4444;
    --color-warning:     #F59E0B;
    --color-info:        #3B82F6;
    --color-success:     #22C55E;

    --color-bg:          #F1F5F9;
    --color-surface:     #FFFFFF;
    --color-surface-alt: #F8FAFC;
    --color-border:      #E2E8F0;
    --color-border-light:#F1F5F9;
    --color-text:        #0F172A;
    --color-text-muted:  #64748B;
    --color-text-soft:   #94A3B8;

    --sidebar-width:     260px;
    --sidebar-width-collapsed: 72px;
    --sidebar-bg:        linear-gradient(180deg, var(--color-primary-900) 0%, var(--color-primary-800) 40%, var(--color-primary-700) 100%);
    --topbar-height:     64px;

    --radius-xs:  4px;
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-xl:  20px;
    --radius-full:9999px;

    --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
    --shadow-xl:  0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);
    --shadow-card:0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.02);
    --shadow-card-hover: 0 8px 25px -5px rgba(0,0,0,.1), 0 4px 10px -3px rgba(0,0,0,.04);
    --shadow-primary: 0 4px 14px color-mix(in srgb, var(--color-primary) 25%, transparent);
    --shadow-glow:   0 0 0 3px color-mix(in srgb, var(--color-primary) 12%, transparent);

    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body:    'Inter', system-ui, -apple-system, sans-serif;
    --transition:   .2s cubic-bezier(.4,0,.2,1);
    --transition-fast: .15s cubic-bezier(.4,0,.2,1);
    --transition-slow: .3s cubic-bezier(.4,0,.2,1);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.011em;
}

::selection {
    background: color-mix(in srgb, var(--color-primary) 20%, transparent);
    color: var(--color-primary-900);
}

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-primary-700); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}
button:focus:not(:focus-visible), .flash-close:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary-900) 0%, var(--color-primary-800) 35%, var(--color-primary-700) 70%, var(--color-primary-600) 100%);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}
.login-body::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(255,255,255,.04) 0%, transparent 60%),
                radial-gradient(circle at 70% 60%, rgba(201,168,76,.06) 0%, transparent 50%);
    animation: login-ambient 20s ease-in-out infinite alternate;
}
@keyframes login-ambient {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(-3%, -2%); }
}

.login-wrapper { width: 100%; max-width: 440px; position: relative; z-index: 1; }

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 2.75rem 2.25rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,.2);
    border: 1px solid rgba(255,255,255,.08);
}

.login-header { text-align: center; margin-bottom: 2.25rem; }
.login-brand {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    color: var(--color-primary);
    margin-bottom: .5rem;
    letter-spacing: -.02em;
}
.login-subtitle { color: var(--color-text-muted); font-size: .925rem; line-height: 1.5; }

.login-form { display: flex; flex-direction: column; gap: 1.35rem; }

.login-footer {
    margin-top: 1.75rem;
    display: flex;
    justify-content: center;
}

.lang-switcher, .lang-switch {
    display: flex;
    gap: .25rem;
    align-items: center;
    font-size: .82rem;
    color: var(--color-text-muted);
    background: var(--color-surface-alt);
    border-radius: var(--radius-full);
    padding: 3px;
}
.lang-switcher a, .lang-switch .lang-btn {
    color: var(--color-text-muted);
    font-weight: 500;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    transition: var(--transition);
    font-size: .8rem;
    letter-spacing: .02em;
}
.lang-switcher a.active, .lang-switch .lang-btn.active {
    color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}
.lang-switcher a:hover, .lang-switch .lang-btn:hover { text-decoration: none; color: var(--color-primary); }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dashboard-body {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    transition: width var(--transition-slow), transform var(--transition-slow), box-shadow var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
    border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 10px; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem;
    min-height: var(--topbar-height);
    position: relative;
}
.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 1.25rem; right: 1.25rem;
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.05));
}

.sidebar-brand {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    word-break: break-word;
    letter-spacing: -.01em;
}

.sidebar-logo { max-height: 38px; width: auto; border-radius: var(--radius-sm); }

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,.6);
    font-size: 1.2rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.sidebar-close:hover { color: #fff; background: rgba(255,255,255,.12); }

.sidebar-nav { flex: 1; padding: .5rem .75rem; }
.sidebar-nav ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .85rem;
    color: rgba(255,255,255,.7);
    font-size: .855rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-decoration: none;
    position: relative;
    letter-spacing: -.005em;
}
.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
    text-decoration: none;
    transform: translateX(3px);
    backdrop-filter: blur(2px);
}
.sidebar-link.active {
    color: #fff;
    background: rgba(255,255,255,.14);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
    backdrop-filter: blur(2px);
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -0.75rem; top: 6px; bottom: 6px;
    width: 3px;
    background: var(--color-accent);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px rgba(201,168,76,.4);
}
.sidebar-link svg { opacity: .75; flex-shrink: 0; transition: opacity var(--transition-fast); }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }
.sidebar-link-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition), width var(--transition-slow);
}

/* Sidebar colapsado (escritorio): solo iconos */
@media (min-width: 769px) {
    html.sidebar-collapsed {
        --sidebar-width: var(--sidebar-width-collapsed);
    }
    html.sidebar-collapsed .sidebar-header {
        justify-content: center;
        padding: 1rem .5rem;
    }
    html.sidebar-collapsed .sidebar-brand,
    html.sidebar-collapsed .sidebar-link-text,
    html.sidebar-collapsed .user-details {
        opacity: 0;
        width: 0;
        overflow: hidden;
        flex: 0;
        padding: 0;
        margin: 0;
    }
    html.sidebar-collapsed .sidebar-link {
        justify-content: center;
        gap: 0;
        padding: .65rem;
    }
    html.sidebar-collapsed .sidebar-link:hover { transform: none; }
    html.sidebar-collapsed .sidebar-link.active::before {
        left: 0;
        top: 4px;
        bottom: 4px;
    }
    html.sidebar-collapsed .sidebar-nav { padding: .5rem .45rem; }
    html.sidebar-collapsed .sidebar-footer {
        justify-content: center;
        padding: .75rem .45rem;
        flex-direction: column;
        gap: .5rem;
    }
    html.sidebar-collapsed .user-info { justify-content: center; }
}

.sidebar-collapse-btn svg.icon-expand { display: none; }
.sidebar-collapse-btn svg.icon-collapse { display: block; }
html.sidebar-collapsed .sidebar-collapse-btn svg.icon-expand { display: block; }
html.sidebar-collapsed .sidebar-collapse-btn svg.icon-collapse { display: none; }

.sidebar-collapse-btn {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,.65);
    padding: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}
.sidebar-collapse-btn:hover { color: #fff; background: rgba(255,255,255,.12); }
@media (min-width: 769px) {
    .sidebar-collapse-btn { display: flex; }
}

.sidebar-collapse-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.sidebar-collapse-toggle:hover { background: var(--color-bg); }
@media (min-width: 769px) {
    .sidebar-collapse-toggle { display: flex; }
}
.sidebar-collapse-toggle svg.icon-expand { display: none; }
.sidebar-collapse-toggle svg.icon-collapse { display: block; }
html.sidebar-collapsed .sidebar-collapse-toggle svg.icon-expand { display: block; }
html.sidebar-collapsed .sidebar-collapse-toggle svg.icon-collapse { display: none; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    position: relative;
    margin-top: auto;
}
.sidebar-footer::before {
    content: '';
    position: absolute;
    top: 0; left: 1.25rem; right: 1.25rem;
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.05));
}

.user-info { flex: 1; display: flex; align-items: center; gap: .65rem; min-width: 0; }
.user-avatar-sm {
    width: 34px; height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.2);
}
.user-avatar-placeholder {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,.2), rgba(255,255,255,.08));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .82rem;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.15);
}
.user-details { min-width: 0; }
.user-name {
    display: block; font-size: .82rem; font-weight: 600; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
    display: block; font-size: .7rem; color: rgba(255,255,255,.55);
    text-transform: capitalize; letter-spacing: .02em;
}

.btn-logout {
    color: rgba(255,255,255,.55);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    flex-shrink: 0;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }

/* --- MAIN WRAPPER --- */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    background: var(--color-bg);
    transition: margin-left var(--transition-slow), width var(--transition-slow);
}

/* --- TOPBAR --- */
.topbar {
    height: var(--topbar-height);
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(16px) saturate(1.8);
    -webkit-backdrop-filter: blur(16px) saturate(1.8);
    border-bottom: 1px solid rgba(226,232,240,.5);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow var(--transition);
}
.topbar.scrolled {
    box-shadow: 0 1px 8px rgba(0,0,0,.06);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--color-bg); }

.page-title-header {
    flex: 1;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.015em;
}

.topbar-right { display: flex; align-items: center; gap: .5rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 190;
    transition: opacity var(--transition-slow);
}

/* --- FLASH / TOAST MESSAGES --- */
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1.75rem;
    font-size: .875rem;
    font-weight: 500;
    animation: flash-in .45s cubic-bezier(.16,1,.3,1);
    border-left: 4px solid transparent;
    position: relative;
    overflow: hidden;
}
.flash::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    background: currentColor;
    opacity: .2;
    animation: flash-timer 5s linear forwards;
}
@keyframes flash-timer {
    from { width: 100%; }
    to   { width: 0%; }
}
@keyframes flash-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes flash-out {
    from { opacity: 1; transform: translateY(0); max-height: 80px; }
    to   { opacity: 0; transform: translateY(-10px); max-height: 0; padding: 0; margin: 0; }
}
.flash-success {
    background: linear-gradient(to right, var(--color-primary-50), color-mix(in srgb, var(--color-primary) 5%, #fff));
    color: var(--color-primary-800);
    border-left-color: var(--color-secondary);
    border-bottom: none;
}
.flash-error {
    background: linear-gradient(to right, #FEF2F2, #FFF1F2);
    color: #9F1239;
    border-left-color: #EF4444;
    border-bottom: none;
}
.flash-warning {
    background: linear-gradient(to right, #FFFBEB, #FEF9C3);
    color: #92400E;
    border-left-color: #F59E0B;
    border-bottom: none;
}
.flash-info {
    background: linear-gradient(to right, #EFF6FF, #DBEAFE);
    color: #1E40AF;
    border-left-color: #3B82F6;
    border-bottom: none;
}
.flash-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: inherit;
    opacity: .45;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
    flex-shrink: 0;
}
.flash-close:hover { opacity: .8; background: rgba(0,0,0,.05); }

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    padding: 1.75rem;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    animation: content-in .35s ease;
}
@keyframes content-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- FOOTER ADMIN --- */
.admin-footer {
    padding: 1.25rem 1.75rem;
    text-align: center;
    font-size: .75rem;
    color: var(--color-text-soft);
    border-top: 1px solid var(--color-border-light);
    margin-top: auto;
}
.admin-footer a { color: var(--color-text-muted); }
.admin-footer a:hover { color: var(--color-primary); }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* --- CARDS --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card--interactive:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}
.card--wide { flex: 1 1 auto; }
.card--alerts { min-width: 280px; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
    gap: 1rem;
    background: var(--color-surface-alt);
}
.card-title {
    font-size: .92rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -.01em;
}
.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }

/* --- METRICS --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--color-primary);
    opacity: 0;
    transition: opacity var(--transition);
}
.metric-card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-3px);
}
.metric-card:hover::before { opacity: 1; }
.metric-card {
    animation: card-stagger .4s ease both;
}
.metric-card:nth-child(1) { animation-delay: 0s; }
.metric-card:nth-child(2) { animation-delay: .05s; }
.metric-card:nth-child(3) { animation-delay: .1s; }
.metric-card:nth-child(4) { animation-delay: .15s; }
@keyframes card-stagger {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.metric-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.metric-icon--blue   { background: linear-gradient(135deg, #DBEAFE, #BFDBFE); color: #1D4ED8; }
.metric-icon--amber  { background: linear-gradient(135deg, #FEF3C7, #FDE68A); color: #D97706; }
.metric-icon--green  { background: linear-gradient(135deg, var(--color-primary-100), var(--color-primary-200)); color: var(--color-primary-600); }
.metric-icon--purple { background: linear-gradient(135deg, #EDE9FE, #DDD6FE); color: #7C3AED; }

.metric-body { min-width: 0; }
.metric-value {
    display: block;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    letter-spacing: -.02em;
}
.metric-label {
    display: block;
    font-size: .78rem;
    color: var(--color-text-muted);
    margin-top: 3px;
    letter-spacing: .01em;
}

/* --- SECTION ROW --- */
.section-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}
/* Solo la columna izquierda directa; las cards anidadas (formularios, fotos…) no deben estirarse ni recortarse */
.section-row > .card { flex: 1 1 300px; }
.appt-detail-col {
    flex: 1 1 320px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.appt-detail-col > .card {
    flex: 0 0 auto;
    overflow: visible;
    height: auto;
}
.appt-forms-card .card-body { overflow: visible; }
.appt-forms-summary {
    display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .85rem;
    font-size: .82rem;
}
.appt-forms-summary span {
    padding: .2rem .55rem; border-radius: 999px; background: var(--color-surface-alt);
    border: 1px solid var(--color-border-light);
}
.appt-forms-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .65rem; }
.appt-form-item {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: .75rem .85rem;
    background: var(--color-surface-alt, #f8fafc);
    display: flex; flex-direction: column; gap: .55rem;
}
.appt-form-item-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.appt-form-item-title { font-size: .88rem; font-weight: 600; line-height: 1.35; color: var(--color-text); flex: 1 1 180px; min-width: 0; }
.appt-form-item-meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.appt-form-item-actions {
    display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
    padding-top: .45rem; border-top: 1px solid var(--color-border-light);
}
.appt-form-item-actions .btn { flex: 0 0 auto; }
.appt-forms-kiosk { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--color-border-light); }
.appt-forms-kiosk form { flex: 1 1 160px; margin: 0; }
.appt-forms-footer { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--color-border-light); }

/* --- MONTHLY STATS --- */
.monthly-stats { display: flex; flex-direction: column; gap: .65rem; }
.stat-row {
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .88rem;
    color: var(--color-text-muted);
    padding: .35rem .5rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.stat-row:hover { background: var(--color-surface-alt); }
.stat-row svg { color: var(--color-primary); flex-shrink: 0; opacity: .8; }
.stat-label { flex: 1; }
.stat-value { font-weight: 600; color: var(--color-text); font-variant-numeric: tabular-nums; }

/* --- ALERT ITEMS --- */
.alert-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem .85rem;
    border-radius: var(--radius-sm);
    margin-bottom: .5rem;
    font-size: .86rem;
    border-left: 3px solid transparent;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item--warning { background: #FFFBEB; color: #92400E; border-left-color: #F59E0B; }
.alert-item--info    { background: #EFF6FF; color: #1E40AF; border-left-color: #3B82F6; }
.alert-item svg { flex-shrink: 0; }
.alert-item a { color: inherit; text-decoration: underline; font-weight: 500; }

/* --- ACTIVITY LIST --- */
.activity-list { list-style: none; }
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .7rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
    font-size: .86rem;
    transition: background var(--transition-fast);
}
.activity-item:hover { background: var(--color-surface-alt); }
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--color-secondary);
    flex-shrink: 0;
    margin-top: 6px;
    box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
.activity-content { flex: 1; min-width: 0; }
.activity-desc { color: var(--color-text); }
.activity-user { color: var(--color-text-muted); }
.activity-time { font-size: .75rem; color: var(--color-text-soft); white-space: nowrap; flex-shrink: 0; }

/* --- TABLES --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
    max-width: 100%;
}
.table-responsive--scroll-hint {
    position: relative;
}
.table-responsive--scroll-hint::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    float: right;
    width: 28px;
    height: 100%;
    margin-left: -28px;
    pointer-events: none;
    background: linear-gradient(to left, var(--color-surface) 20%, transparent);
}
.card--table { overflow: visible; }
.card--table .table-responsive {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .7rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--color-border);
}
.table td {
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
    color: var(--color-text);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover td { background: var(--color-surface-alt); }
.text-nowrap { white-space: nowrap; }
.text-muted { color: var(--color-text-muted); font-size: .82rem; }

.table tbody tr {
    animation: row-in .3s ease both;
}
.table tbody tr:nth-child(1)  { animation-delay: 0s; }
.table tbody tr:nth-child(2)  { animation-delay: .02s; }
.table tbody tr:nth-child(3)  { animation-delay: .04s; }
.table tbody tr:nth-child(4)  { animation-delay: .06s; }
.table tbody tr:nth-child(5)  { animation-delay: .08s; }
.table tbody tr:nth-child(6)  { animation-delay: .1s; }
.table tbody tr:nth-child(7)  { animation-delay: .12s; }
.table tbody tr:nth-child(8)  { animation-delay: .14s; }
.table tbody tr:nth-child(9)  { animation-delay: .16s; }
.table tbody tr:nth-child(10) { animation-delay: .18s; }
@keyframes row-in {
    from { opacity: 0; transform: translateX(-4px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .575rem 1.15rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: -.005em;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
}
.btn-primary:hover {
    background: var(--color-primary-700);
    border-color: var(--color-primary-700);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

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

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-outline:hover {
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
    box-shadow: 0 1px 2px rgba(239,68,68,.2);
}
.btn-danger:hover { background: #DC2626; border-color: #DC2626; color: #fff; }

.btn-outline-danger {
    background: transparent;
    color: var(--color-danger);
    border-color: var(--color-danger);
}
.btn-outline-danger:hover {
    background: var(--color-danger);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239,68,68,.25);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-border);
}
.btn-ghost:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
    border-color: var(--color-text-soft);
}

.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: .4rem .85rem; font-size: .82rem; border-radius: var(--radius-sm); }
.btn-xs   { padding: .25rem .6rem; font-size: .78rem; border-radius: var(--radius-xs); }

/* --- FORMS --- */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-label {
    font-size: .855rem;
    font-weight: 500;
    color: var(--color-text);
    letter-spacing: -.005em;
}
.form-label.required::after { content: ' *'; color: var(--color-danger); font-weight: 400; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: .625rem .9rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
}
.form-input::placeholder, .form-textarea::placeholder {
    color: var(--color-text-soft);
}
.form-input:hover, .form-select:hover, .form-textarea:hover {
    border-color: var(--color-text-soft);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}
.form-input.error, .form-select.error {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(239,68,68,.1);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: .78rem; color: var(--color-text-soft); }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.input-with-toggle { position: relative; }
.input-with-toggle .form-input { padding-right: 2.5rem; }
.toggle-password {
    position: absolute;
    right: .6rem; top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-soft);
    padding: 4px;
    display: flex; align-items: center;
    transition: var(--transition);
    border-radius: var(--radius-xs);
}
.toggle-password:hover { color: var(--color-text); background: var(--color-surface-alt); }

/* --- ALERTS (form level) --- */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .875rem;
    border-left: 4px solid transparent;
}
.alert p { margin: 0; }
.alert p + p { margin-top: .25rem; }
.alert-error   { background: #FEF2F2; color: #991B1B; border-left-color: #EF4444; }
.alert-success { background: #F0FDF4; color: #166534; border-left-color: #22C55E; }
.alert-warning { background: #FFFBEB; color: #92400E; border-left-color: #F59E0B; }
/* `alert-info` ya se usaba en las vistas pero no tenía color propio. */
.alert-info    { background: #EFF6FF; color: #1E40AF; border-left-color: #3B82F6; }
.alert-warning-text { color: #92400E; font-size: .875rem; }

/* --- BADGES --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .65rem;
    border-radius: var(--radius-full);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: .01em;
    line-height: 1.5;
}
.badge-scheduled   { background: #EFF6FF; color: #1D4ED8; }
.badge-confirmed   { background: var(--color-primary-50); color: var(--color-primary-800); }
.badge-checked-in  { background: #EEF2FF; color: #3730A3; }
.badge-in-progress { background: #FFFBEB; color: #B45309; }
.badge-completed   { background: #F8FAFC; color: #475569; }
.badge-cancelled   { background: #FEF2F2; color: #991B1B; }
.badge-no-show     { background: #FFF1F2; color: #9F1239; }
.badge-default     { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* --- MODALS --- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.modal--open {
    display: flex;
}
.modal-dialog {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-in .25s cubic-bezier(.16,1,.3,1);
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(-16px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
}
.modal-title { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--color-text-soft);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.modal-close:hover { background: var(--color-surface-alt); color: var(--color-text); }
.modal-body { padding: 1.25rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    color: var(--color-text-soft);
    padding: 3rem 1.5rem;
    font-size: .9rem;
    line-height: 1.6;
}
.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--color-surface-alt);
    margin: 0 auto 1rem;
    color: var(--color-text-soft);
}
.empty-state-icon svg { width: 24px; height: 24px; }
.empty-state-title {
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: .35rem;
    font-size: .95rem;
}

/* --- TABS --- */
.tabs-container { margin-bottom: .5rem; }
.tabs-header {
    display: flex;
    gap: .15rem;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0;
}
.tabs-header::-webkit-scrollbar { display: none; }
.tab-trigger {
    position: relative;
    padding: .7rem 1.25rem;
    font-size: .86rem;
    font-weight: 500;
    color: var(--color-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-trigger:hover {
    color: var(--color-primary);
    background: var(--color-primary-50);
}
.tab-trigger.active {
    color: var(--color-primary);
    font-weight: 600;
    border-bottom-color: var(--color-primary);
    background: var(--color-primary-50);
}
.tab-panel.active { display: block; }

/* --- STAFF PROFILE HEADER --- */
.staff-profile-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--color-primary-50) 0%, rgba(167,243,208,.15) 100%);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}
.staff-avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--color-surface);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}
.staff-avatar-placeholder-lg {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-700));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
}
.staff-header-info { flex: 1; min-width: 0; }
.staff-header-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: var(--font-heading);
    margin-bottom: .3rem;
    letter-spacing: -.01em;
}
.staff-header-meta {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: .84rem;
    color: var(--color-text-muted);
}
.staff-header-meta .badge { font-size: .72rem; }

/* --- FORM ACTIONS BAR --- */
.form-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.15rem 0;
    margin-top: 1rem;
    border-top: 1px solid var(--color-border);
}
.form-actions .btn-primary {
    padding: .625rem 2rem;
    font-size: .9rem;
    font-weight: 600;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    :root { --sidebar-width: 240px; }
}

@media (max-width: 768px) {
    html.sidebar-collapsed { --sidebar-width: 260px; }
    .sidebar {
        transform: translateX(-100%);
        width: 270px;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }
    .sidebar-close { display: flex; }
    .sidebar-overlay.visible { display: block; }

    .main-wrapper { margin-left: 0; width: 100%; }
    .sidebar-toggle { display: flex; }
    .sidebar-collapse-toggle,
    .sidebar-collapse-btn { display: none !important; }
    .topbar { padding: 0 1rem; }
    .main-content { padding: 1rem; }

    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .section-row { flex-direction: column; }
    .form-row { grid-template-columns: 1fr; }
    .breadcrumbs { display: none; }
    .modal-dialog { max-width: 100%; margin: .5rem; }
}

@media (max-width: 480px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .login-card { padding: 2rem 1.25rem; }
    .topbar { gap: .5rem; }
    .page-title-header { font-size: .9rem; }
    .pagination { padding: .75rem; }
    .page-btn { min-width: 30px; height: 30px; font-size: .75rem; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.d-flex  { display: flex; }
.gap-1   { gap: .5rem; }
.gap-2   { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1  { flex: 1; }
.mt-1    { margin-top: .5rem; }
.mt-2    { margin-top: 1rem; }
.mt-3    { margin-top: 1.5rem; }
.mb-1    { margin-bottom: .5rem; }
.mb-2    { margin-bottom: 1rem; }
.mb-3    { margin-bottom: 1.5rem; }
.p-0     { padding: 0; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.w-full  { width: 100%; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--color-primary); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* --- AVATARS GLOBAL --- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    color: var(--color-primary);
    border: 2px solid var(--color-border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: .6rem; }
.avatar-sm { width: 32px; height: 32px; font-size: .72rem; }
.avatar-md { width: 40px; height: 40px; font-size: .82rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.25rem; }

/* --- STATUS DOT --- */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot--active { background: var(--color-success); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-success) 20%, transparent); }
.status-dot--inactive { background: var(--color-text-soft); }
.status-dot--warning { background: var(--color-warning); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-warning) 20%, transparent); }
.status-dot--danger { background: var(--color-danger); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-danger) 20%, transparent); }

/* --- PAGINATION GLOBAL --- */
.pagination {
    display: flex;
    gap: .25rem;
    padding: 1rem 1.25rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: .25rem .55rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-surface);
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}
.page-btn:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    text-decoration: none;
    box-shadow: var(--shadow-primary);
}
.page-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    font-weight: 600;
    box-shadow: var(--shadow-primary);
}
.page-btn.disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}
.page-info {
    font-size: .82rem;
    color: var(--color-text-muted);
    padding: 0 .5rem;
}

/* --- BREADCRUMBS --- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--color-text-soft);
    margin-bottom: 1rem;
}
.breadcrumbs a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}
.breadcrumbs a:hover { color: var(--color-primary); }
.breadcrumbs .separator { color: var(--color-border); }
.breadcrumbs .current { color: var(--color-text); font-weight: 500; }

/* --- TOOLTIPS --- */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) scale(.92);
    background: var(--color-text);
    color: #fff;
    padding: .35rem .65rem;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s, transform .15s;
    z-index: 50;
    box-shadow: var(--shadow-md);
}
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* --- LOADING / SKELETON --- */
.skeleton {
    background: linear-gradient(90deg, var(--color-surface-alt) 25%, var(--color-border-light) 50%, var(--color-surface-alt) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-text { height: .875rem; margin-bottom: .5rem; }
.skeleton-text:last-child { width: 60%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-card { height: 80px; }

.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- LOADING OVERLAY --- */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- BTN GROUP GLOBAL --- */
.btn-group { display: flex; }
.btn-group .btn { border-radius: 0; border-right-width: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-right-width: 1px; }
.btn-group .btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* --- DATA COUNT / RESULTS BADGE --- */
.results-count {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--color-text-muted);
    padding: .25rem .65rem;
    background: var(--color-surface-alt);
    border-radius: var(--radius-full);
    font-weight: 500;
}

/* --- SEARCH BAR GLOBAL --- */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}
.search-bar svg {
    position: absolute;
    left: .7rem;
    width: 16px; height: 16px;
    color: var(--color-text-soft);
    pointer-events: none;
}
.search-bar .form-input {
    padding-left: 2.25rem;
    font-size: .86rem;
}

/* --- SCROLLBAR GLOBAL --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-soft); }

/* --- SERVICES LIST --- */
.svc-stats { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.svc-stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: .85rem 1rem; display: flex; align-items: center; gap: .7rem; }
.svc-stat-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.svc-stat-icon svg { width: 18px; height: 18px; }
.svc-stat-icon--blue   { background: color-mix(in srgb, var(--color-info) 12%, transparent); color: var(--color-info); }
.svc-stat-icon--green  { background: color-mix(in srgb, var(--color-success) 12%, transparent); color: var(--color-success); }
.svc-stat-icon--gold   { background: color-mix(in srgb, var(--color-accent) 15%, transparent); color: var(--color-accent); }
.svc-stat-icon--purple { background: color-mix(in srgb, #8B5CF6 12%, transparent); color: #8B5CF6; }
.svc-stat-val { font-size: 1.15rem; font-weight: 700; color: var(--color-text); line-height: 1.1; }
.svc-stat-lbl { font-size: .72rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }

.svc-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem; margin-bottom: 1rem; }
.svc-toolbar-left  { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.svc-toolbar-right { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.svc-search { position: relative; }
.svc-search input { padding: .45rem .7rem .45rem 2rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: .82rem; background: var(--color-surface); width: 220px; transition: border var(--transition); }
.svc-search input:focus { outline: none; border-color: var(--color-primary); }
.svc-search svg { position: absolute; left: .55rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--color-text-soft); pointer-events: none; }
.svc-count { font-size: .78rem; color: var(--color-text-muted); padding: .3rem .65rem; background: var(--color-surface-alt); border-radius: var(--radius-full); }

.svc-table { min-width: 960px; }
.svc-table th[data-sort] { cursor: pointer; user-select: none; position: relative; padding-right: 1.4rem !important; }
.svc-table th[data-sort]:hover { color: var(--color-primary); }
.svc-table th[data-sort]::after { content: '\21C5'; position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); font-size: .7rem; opacity: .35; }
.svc-table th[data-sort].sort-asc::after  { content: '\2191'; opacity: .8; color: var(--color-primary); }
.svc-table th[data-sort].sort-desc::after { content: '\2193'; opacity: .8; color: var(--color-primary); }

.svc-name-cell { display: flex; align-items: center; gap: .6rem; }
.svc-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.svc-name-main { font-weight: 600; color: var(--color-text); line-height: 1.3; }
.svc-name-sub  { font-size: .75rem; color: var(--color-text-muted); }
.svc-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.svc-duration { display: inline-flex; align-items: center; gap: .25rem; font-size: .82rem; color: var(--color-text-muted); }
.svc-duration svg { width: 13px; height: 13px; }
.svc-actions {
    white-space: nowrap;
    text-align: right;
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--color-surface);
    box-shadow: -6px 0 10px rgba(15, 23, 42, .04);
}
.svc-table thead th.svc-actions-head {
    position: sticky;
    right: 0;
    z-index: 3;
    background: var(--color-surface-alt);
    box-shadow: -6px 0 10px rgba(15, 23, 42, .04);
}
.svc-table tbody tr:hover .svc-actions { background: var(--color-surface-alt); }
.svc-table .col-name {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--color-surface);
    min-width: 160px;
    max-width: 220px;
}
.svc-table thead .col-name {
    z-index: 3;
    background: var(--color-surface-alt);
}
.svc-table tbody tr:hover .col-name { background: var(--color-surface-alt); }

.svc-forms-cell { min-width: 120px; max-width: 180px; vertical-align: top; }
.svc-form-chips { display: flex; flex-direction: column; gap: .3rem; }
.svc-form-chip {
    display: inline-block; max-width: 100%;
    font-size: .72rem; line-height: 1.35; padding: .2rem .45rem;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.svc-form-chip--patient { background: rgba(37, 99, 235, .1); color: #1d4ed8; border-color: rgba(37, 99, 235, .22); }
.svc-form-chip--staff   { background: rgba(124, 58, 237, .1); color: #6d28d9; border-color: rgba(124, 58, 237, .22); }
.svc-form-chip-req { color: #dc2626; font-weight: 700; margin-left: .1rem; }
.svc-forms-none { font-size: .78rem; color: var(--color-text-soft); font-style: italic; }

@media (max-width: 1400px) {
    .svc-table .col-cat,
    .svc-table .col-feat,
    .svc-table .col-comm { display: none; }
}
@media (max-width: 1100px) {
    .svc-table .col-dur { display: none; }
    .svc-forms-cell { max-width: 140px; }
}
@media (max-width: 768px) {
    .svc-toolbar { flex-direction: column; align-items: stretch; }
    .svc-search input { width: 100%; }
    .svc-table { min-width: 720px; }
    .svc-table .col-staff { display: none; }
}

/* --- Settings: color pickers de estados --- */
.settings-colors-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.settings-color-item { display: flex; flex-direction: column; gap: .25rem; }
.settings-color-input { width: 100%; height: 38px; padding: 2px; border: 1px solid var(--color-border); border-radius: 8px; cursor: pointer; background: var(--color-surface); }

/* --- CALENDAR (appointments) — agenda profesional --- */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.cal-toolbar-group { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
/* Fecha de la barra: es un botón que abre el mini calendario */
.cal-label {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-width: 200px; text-align: center; font-size: 1rem; font-weight: 600;
    font-family: inherit; color: var(--color-text);
    padding: .3rem .7rem; border: 1.5px solid transparent; border-radius: var(--radius-sm);
    background: none; cursor: pointer; transition: var(--transition);
}
.cal-label:hover { background: var(--color-surface-alt); border-color: var(--color-border); }
.cal-label--open, .cal-label:focus-visible {
    outline: none; background: var(--color-surface);
    border-color: var(--color-primary); box-shadow: var(--shadow-glow);
}
.cal-label-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--color-primary); }

/* Mini calendario para saltar de fecha */
.cal-dp {
    position: fixed; z-index: 400; width: 268px; padding: .6rem;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-xl);
    animation: modal-in .16s cubic-bezier(.16,1,.3,1);
}
.cal-dp[hidden] { display: none; }
.cal-dp-head { display: flex; align-items: center; gap: .15rem; margin-bottom: .4rem; }
.cal-dp-title { flex: 1; text-align: center; font-size: .88rem; font-weight: 600; }
.cal-dp-nav {
    width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    border: none; border-radius: var(--radius-xs); background: none; cursor: pointer;
    color: var(--color-text-muted); font-size: .95rem; font-family: inherit; line-height: 1;
    transition: var(--transition-fast);
}
.cal-dp-nav:hover { background: var(--color-primary-50); color: var(--color-primary); }
.cal-dp-dows, .cal-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dp-dows span {
    text-align: center; font-size: .68rem; font-weight: 600; padding: .2rem 0;
    color: var(--color-text-soft); text-transform: uppercase;
}
.cal-dp-day {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    border: 1.5px solid transparent; border-radius: var(--radius-xs);
    background: none; cursor: pointer; font-family: inherit; font-size: .8rem;
    color: var(--color-text); transition: var(--transition-fast);
}
.cal-dp-day:hover { background: var(--color-primary-100); }
.cal-dp-day--out { color: var(--color-text-soft); }
.cal-dp-day--today { border-color: var(--color-primary); font-weight: 700; }
.cal-dp-day--range { background: var(--color-primary-50); }
.cal-dp-day--sel {
    background: var(--color-primary); border-color: var(--color-primary);
    color: #fff; font-weight: 700;
}
.cal-dp-day--sel:hover { background: var(--color-primary-600); }
.cal-dp-foot {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--color-border-light);
}
.cal-dp-hint { font-size: .66rem; color: var(--color-text-soft); }
@media (max-width: 480px) {
    .cal-label { min-width: 0; }
    .cal-dp-hint { display: none; }
}
.cal-view-switch .btn.active { background: var(--color-primary); color: #fff; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: .6rem; font-size: .76rem; color: var(--color-text-muted); }
.cal-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.cal-legend-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.cal-legend-block { background: repeating-linear-gradient(45deg,#cbd5e1,#cbd5e1 3px,#e2e8f0 3px,#e2e8f0 6px); }
.cal-card { overflow: hidden; }
.cal-body-wrap { min-height: 480px; }

/* Rejilla horaria (día / semana) */
.cal-tt { display: flex; flex-direction: column; }
.cal-tt-head { display: flex; border-bottom: 2px solid var(--color-border); background: var(--color-surface); }
.cal-tt-gutter-h { width: 60px; flex: 0 0 60px; border-right: 1px solid var(--color-border); }
.cal-tt-dayhdr { flex: 1 1 0; text-align: center; padding: .4rem .25rem; font-size: .8rem; font-weight: 600; border-left: 1px solid var(--color-border); }
.cal-tt-dayhdr.today { color: var(--color-primary); }
.cal-tt-dayhdr .dwn { display: block; font-size: .68rem; color: var(--color-text-muted); font-weight: 400; text-transform: uppercase; }
.cal-tt-dayhdr .dnum { font-size: 1.15rem; font-weight: 700; }

.cal-tt-body { display: flex; max-height: 70vh; overflow-y: auto; position: relative; }
.cal-tt-gutter { width: 60px; flex: 0 0 60px; position: relative; }
.cal-tt-hourlabel { font-size: .68rem; color: var(--color-text-muted); text-align: right; padding-right: .35rem; box-sizing: border-box; border-right: 1px solid var(--color-border); transform: translateY(-6px); }
.cal-tt-cols { flex: 1 1 0; display: flex; }
.cal-tt-day { flex: 1 1 0; position: relative; border-left: 1px solid var(--color-border); touch-action: none; }
.cal-tt-hourline { border-bottom: 1px solid var(--color-border); box-sizing: border-box; }
.cal-tt-hourline:nth-child(odd) { background: color-mix(in srgb, var(--color-border) 8%, transparent); }

/* Evento (cita) */
.cal-ev { position: absolute; left: 2px; right: 2px; border-radius: 6px; color: #fff; padding: 2px 6px 6px; font-size: .72rem; overflow: hidden; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.15); line-height: 1.15; user-select: none; }
.cal-ev:hover { filter: brightness(1.05); }
.cal-ev.dragging { opacity: .8; cursor: grabbing; z-index: 20; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.cal-ev-time { font-weight: 700; }
.cal-ev-name { font-weight: 600; }
.cal-ev-svc { display: block; opacity: .9; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.cal-ev-resize::after { content: ''; position: absolute; left: 50%; bottom: 2px; width: 22px; height: 3px; transform: translateX(-50%); background: rgba(255,255,255,.6); border-radius: 2px; }
.cal-ev-sel { position: absolute; left: 2px; right: 2px; background: color-mix(in srgb, var(--color-primary) 25%, transparent); border: 1.5px dashed var(--color-primary); border-radius: 6px; z-index: 15; }

/* Zona bloqueada */
.cal-block-zone { position: absolute; left: 2px; right: 2px; border-radius: 6px; background: repeating-linear-gradient(45deg, rgba(148,163,184,.32), rgba(148,163,184,.32) 6px, rgba(148,163,184,.16) 6px, rgba(148,163,184,.16) 12px); border: 1px solid #cbd5e1; z-index: 5; overflow: hidden; }
.cal-block-label { font-size: .68rem; color: #475569; font-weight: 600; padding: 2px 4px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-block-del { position: absolute; top: 1px; right: 2px; background: transparent; border: none; color: #64748b; font-size: .95rem; line-height: 1; cursor: pointer; }
.cal-block-del:hover { color: var(--color-danger); }

/* Línea de ahora */
.cal-now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid #ef4444; z-index: 18; pointer-events: none; }
.cal-now-dot { position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; }

/* Cronograma horizontal (timeline) */
.cal-tl { overflow: auto; max-height: 72vh; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); }
.cal-tl-head { display: flex; position: sticky; top: 0; z-index: 20; background: var(--color-surface); border-bottom: 2px solid var(--color-border); }
.cal-tl-corner { flex: 0 0 160px; width: 160px; position: sticky; left: 0; z-index: 21; background: var(--color-surface); border-right: 2px solid var(--color-border); padding: .5rem .65rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--color-text-muted); display: flex; align-items: center; }
.cal-tl-hours { display: flex; }
.cal-tl-hourlab { flex: 0 0 auto; font-size: .72rem; font-weight: 600; color: var(--color-text-muted); padding: .45rem .3rem .45rem .5rem; border-left: 1px solid var(--color-border); box-sizing: border-box; display: flex; justify-content: flex-start; align-items: center; gap: 0; position: relative; }
.cal-tl-hourlab .cal-tl-hlab { font-weight: 700; color: var(--color-text); }
.cal-tl-hourlab .cal-tl-qlab { flex: 1 1 0; text-align: left; padding-left: .35rem; opacity: .45; font-weight: 500; font-size: .62rem; }
.cal-tl-body { }
.cal-tl-row { display: flex; border-bottom: 1px solid var(--color-border); }
.cal-tl-row:nth-child(even) .cal-tl-name { background: color-mix(in srgb, var(--color-border) 6%, var(--color-surface)); }
.cal-tl-name { flex: 0 0 160px; width: 160px; position: sticky; left: 0; z-index: 10; background: var(--color-surface); border-right: 2px solid var(--color-border); padding: .6rem .65rem; font-size: .82rem; font-weight: 600; display: flex; align-items: flex-start; }
.cal-tl-track { position: relative; min-height: 56px; flex: 0 0 auto; cursor: copy; }
.cal-tl-ev { position: absolute; border-radius: 7px; color: #fff; padding: .2rem .45rem; font-size: .72rem; overflow: hidden; cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.22); z-index: 6; user-select: none; display: flex; flex-direction: column; justify-content: center; gap: 1px; line-height: 1.12; }
.cal-tl-ev:hover { filter: brightness(1.05); z-index: 8; }
.cal-tl-ev:active { cursor: grabbing; }
.cal-tl-ev.dragging { opacity: .85; z-index: 30; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.cal-tl-ev .cal-ev-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-tl-ev .cal-ev-svc { opacity: .92; font-size: .66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-tl-ev-resize { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: ew-resize; }
.cal-tl-block { position: absolute; border-radius: 6px; background: repeating-linear-gradient(45deg, rgba(148,163,184,.34), rgba(148,163,184,.34) 6px, rgba(148,163,184,.16) 6px, rgba(148,163,184,.16) 12px); border: 1px solid #cbd5e1; z-index: 4; overflow: hidden; }
.cal-tl-block-label { font-size: .66rem; color: #475569; padding: .15rem .3rem; display: inline-block; white-space: nowrap; }
.cal-tl-sel { position: absolute; top: 4px; bottom: 4px; background: color-mix(in srgb, var(--color-primary) 25%, transparent); border: 1.5px dashed var(--color-primary); border-radius: 6px; z-index: 15; }
.cal-tl-now { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #ef4444; z-index: 18; pointer-events: none; }

/* Tooltip flotante de cita (hover, estilo tarjeta) */
.cal-ev-tip { position: fixed; z-index: 1200; min-width: 240px; max-width: 320px; background: #1e293b; color: #f1f5f9; border-radius: 10px; padding: .6rem .75rem; font-size: .74rem; box-shadow: 0 10px 28px rgba(0,0,0,.38); pointer-events: none; line-height: 1.4; }
.cal-ev-tip .cal-tip-name { font-weight: 700; font-size: .86rem; margin-bottom: .35rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.cal-ev-tip .cal-tip-status { font-size: .62rem; font-weight: 700; color: #fff; padding: .12rem .45rem; border-radius: 999px; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.cal-ev-tip .cal-tip-row { display: flex; justify-content: space-between; gap: .75rem; padding: .12rem 0; }
.cal-ev-tip .cal-tip-row > span:first-child { color: #94a3b8; flex: 0 0 auto; }
.cal-ev-tip .cal-tip-row strong { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.cal-tip-paid { background: #16a34a; color: #fff; font-weight: 700; padding: .06rem .45rem; border-radius: 5px; font-size: .68rem; letter-spacing: .02em; }
.cal-tip-due { color: #fbbf24; font-weight: 600; }
.cal-tip-hint { margin-top: .45rem; padding-top: .38rem; border-top: 1px solid rgba(148,163,184,.28); color: #94a3b8; font-size: .66rem; }

/* Campos de hora en formato de reloj (2:00 PM) */
.tf-input { font-variant-numeric: tabular-nums; }
.tf-input--bad { border-color: var(--color-danger, #ef4444); background: #fef2f2; }

/* Citas con varios servicios: se marcan en el bloque y se listan en el globo */
.cal-ev-more { display: inline-block; background: rgba(255,255,255,.34); border-radius: 4px; padding: 0 .22rem; font-weight: 700; font-size: .62rem; vertical-align: baseline; }
.cal-ev--multi { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.7); }
.cal-tl-ev--line { box-sizing: border-box; border: 2px dashed rgba(255,255,255,.85); opacity: .96; }
.cal-ev-tip .cal-tip-svc-staff { color: #cbd5e1; flex: 0 0 auto; font-size: .66rem; font-style: italic; }
.av-line-staff { font-size: .78rem; min-width: 90px; }
.cal-ev-tip .cal-tip-svcs-wrap { padding: .12rem 0; }
.cal-ev-tip .cal-tip-svcs-title { color: #94a3b8; }
.cal-ev-tip .cal-tip-svcs { margin-top: .18rem; border-left: 2px solid rgba(148,163,184,.4); padding-left: .45rem; }
.cal-ev-tip .cal-tip-svc { display: flex; gap: .5rem; align-items: baseline; padding: .08rem 0; }
.cal-ev-tip .cal-tip-svc > span:first-child { font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.cal-ev-tip .cal-tip-svc strong { flex: 1; font-weight: 600; text-align: left; overflow-wrap: anywhere; }
.cal-ev-tip .cal-tip-svc > span:last-child { color: #94a3b8; flex: 0 0 auto; font-size: .66rem; }

/* Ayuda simple bajo la leyenda */
.cal-help { margin: .35rem 0 .6rem; padding: .5rem .85rem; background: color-mix(in srgb, var(--color-primary) 7%, transparent); border: 1px solid color-mix(in srgb, var(--color-primary) 18%, transparent); border-radius: 10px; font-size: .9rem; color: var(--color-text); }

/* Botón "Bloquear tiempo" armado + arrastre para bloquear */
#cal-block-btn.active { background: #475569; border-color: #475569; color: #fff; }
.cal-blockmode-hint { margin: -.25rem 0 .6rem; padding: .5rem .85rem; background: color-mix(in srgb, #94a3b8 20%, transparent); border: 1px solid #cbd5e1; border-radius: 10px; font-size: .9rem; color: #334155; }
.cal-blockmode .cal-tt-day, .cal-blockmode .cal-tl-track { cursor: cell; }
.cal-sel-block { background: repeating-linear-gradient(45deg, rgba(71,85,105,.30), rgba(71,85,105,.30) 6px, rgba(71,85,105,.14) 6px, rgba(71,85,105,.14) 12px) !important; border: 1.5px dashed #475569 !important; }

/* Menú rápido tras tocar/arrastrar una hora (cita o bloqueo) */
.cal-quickmenu { position: fixed; z-index: 1100; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.22); padding: .5rem; min-width: 210px; display: flex; flex-direction: column; gap: .4rem; }
.cal-quickmenu-time { font-size: .82rem; font-weight: 700; color: var(--color-text-muted); text-align: center; padding: .15rem 0 .35rem; border-bottom: 1px solid var(--color-border); }
.cal-qm-btn { font-size: 1rem; font-weight: 600; padding: .7rem .8rem; border-radius: 10px; border: none; cursor: pointer; text-align: left; transition: filter var(--transition-fast); }
.cal-qm-btn:hover { filter: brightness(.96); }
.cal-qm-appt { background: var(--color-primary); color: #fff; }
.cal-qm-block { background: #475569; color: #fff; }

/* Mover/reprogramar cita desde la vista rápida */
.cal-move-box { margin-top: .6rem; padding: .6rem .7rem; background: color-mix(in srgb, var(--color-primary) 6%, transparent); border: 1px solid color-mix(in srgb, var(--color-primary) 18%, transparent); border-radius: 10px; }
.cal-move-row { display: flex; gap: .4rem; margin-top: .35rem; flex-wrap: wrap; }
.cal-move-row .form-input { flex: 1 1 120px; min-width: 110px; }
.cal-move-row .btn { flex: 0 0 auto; }

/* Varios servicios con su hora dentro de la misma cita */
.av-lines { list-style: none; margin: .3rem 0 0; padding: 0; font-size: .82rem; }
.av-lines li { display: flex; align-items: baseline; gap: .5rem; padding: .18rem 0; }
.av-lines li + li { border-top: 1px dashed color-mix(in srgb, var(--color-border) 70%, transparent); }
.av-line-when { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-primary); min-width: 46px; }
.av-line-name { flex: 1; min-width: 0; }
.cal-extra-svc { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-bottom: .4rem; }
.cal-extra-svc .cal-extra-svc-select { flex: 1 1 180px; min-width: 150px; }
.cal-extra-svc .cal-extra-staff { flex: 1 1 140px; min-width: 120px; }
.cal-extra-svc .cal-extra-time { flex: 0 0 126px; max-width: 126px; }
.cal-extra-svc .cal-extra-dur  { flex: 0 0 84px;  max-width: 84px; }
.cal-extra-svc .cal-extra-del  { flex: 0 0 auto; color: var(--color-danger); }
.cal-move-row--add-line { flex-wrap: wrap; }

/* Mes */
.cal-month-grid { display: grid; grid-template-columns: repeat(7,1fr); }
.cal-month-header { text-align: center; padding: .5rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; color: var(--color-text-muted); border-bottom: 2px solid var(--color-border); }
.cal-day { border: 1px solid var(--color-border); min-height: 104px; padding: .375rem; cursor: pointer; transition: background var(--transition-fast); position: relative; display: flex; flex-direction: column; }
.cal-day-appts { margin-top: .2rem; max-height: 92px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.cal-day-appts::-webkit-scrollbar { width: 6px; }
.cal-day-appts::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--color-border) 60%, transparent); border-radius: 3px; }
.cal-day:hover { background: color-mix(in srgb, var(--color-primary) 3%, transparent); }
.cal-day--other { background: var(--color-bg); }
.cal-day--today { background: color-mix(in srgb, var(--color-primary) 6%, transparent); }
.cal-day--today .cal-day-num { background: var(--color-primary); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal-day-num { font-size: .82rem; font-weight: 600; margin-bottom: .25rem; }
.cal-day-count { position: absolute; top: .35rem; right: .4rem; font-size: .66rem; font-weight: 700; background: var(--color-primary); color: #fff; border-radius: 999px; padding: 0 .35rem; }
.cal-day-blocked { position: absolute; top: .3rem; right: 1.7rem; font-size: .7rem; }
.cal-appt-pill { font-size: .72rem; padding: .15rem .4rem; border-radius: 100px; color: #fff; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-appt-pill--draggable { cursor: grab; user-select: none; touch-action: none; }
.cal-appt-pill--draggable:active { cursor: grabbing; }
.cal-appt-pill.dragging { opacity: .7; box-shadow: 0 4px 12px rgba(0,0,0,.25); position: relative; z-index: 5; }
.cal-day--drop-target { background: color-mix(in srgb, var(--color-primary) 14%, transparent) !important; outline: 2px dashed var(--color-primary); outline-offset: -2px; }
.cal-more { font-size: .72rem; color: var(--color-primary); cursor: pointer; }

/* Modales de la agenda */
.cal-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 1.25rem 1rem; overflow-y: auto; }
.cal-modal[hidden] { display: none; }
.cal-modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); }
.cal-modal-box {
    position: relative; background: var(--color-surface); border-radius: 12px; width: 100%;
    max-width: 560px; max-height: calc(100vh - 2.5rem); margin: auto 0;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.cal-modal-sm { max-width: 420px; }
.cal-modal-appt { max-width: 480px; }
.cal-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.cal-modal-head h3 { margin: 0; font-size: 1.05rem; }
.cal-modal-x { background: none; border: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--color-text-muted); }
.cal-modal-body { padding: 1.25rem; }
.cal-modal-scroll {
    flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto;
    padding: 1rem 1.25rem; -webkit-overflow-scrolling: touch;
}
.cal-form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }
.cal-form-row .form-group:only-child { grid-column: 1 / -1; }
.cal-modal-foot {
    display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem;
    flex-shrink: 0; margin-top: 0; padding: .85rem 1.25rem 1rem;
    border-top: 1px solid var(--color-border); background: var(--color-surface);
    box-shadow: 0 -6px 16px rgba(15, 23, 42, .06);
}
.cal-modal-foot-primary,
.cal-modal-foot-secondary { display: flex; flex-wrap: wrap; gap: .5rem; width: 100%; }
.cal-modal-foot--stacked { flex-direction: column; align-items: stretch; }
.cal-modal-foot .btn { flex: 1 1 calc(50% - .25rem); min-width: 0; justify-content: center; text-align: center; white-space: normal; line-height: 1.25; }
.cal-modal-foot-primary .btn-primary { flex: 1 1 100%; }
form.cal-modal-body--flex {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
    padding: 0; overflow: hidden;
}
.cal-modal-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fca5a5; border-radius: 6px; padding: .5rem .75rem; font-size: .82rem; margin-top: .5rem; }

/* Panel lateral agenda + paciente */
.cal-layout { display: flex; gap: 1rem; align-items: flex-start; }
.cal-main { flex: 1; min-width: 0; }
.cal-layout--open .cal-main { flex: 1; }
.cal-side-panel {
    width: 360px; max-width: 100%; flex-shrink: 0;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.08);
    position: sticky; top: 1rem; max-height: calc(100vh - 2rem);
    display: flex; flex-direction: column; overflow: hidden;
}
.cal-side-panel[hidden] { display: none !important; }
.cal-side-head { display: flex; justify-content: space-between; align-items: center; padding: .85rem 1rem; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.cal-side-head h3 { margin: 0; font-size: 1rem; }
.cal-side-body { padding: 1rem; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cal-side-section { margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--color-border); }
.cal-side-section:last-of-type { border-bottom: none; }
.cal-side-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); margin: 0 0 .35rem; }
.cal-side-note { background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 6px; padding: .5rem .65rem; margin-bottom: .4rem; }
.cal-side-note p { margin: 0; font-size: .85rem; }
.cal-side-note small { color: var(--color-text-muted); }
.cal-side-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
/* Botones de la cita al inicio del panel, en dos columnas parejas. */
.cal-side-actions--top { margin-top: .6rem; }
.cal-side-actions--top .btn { flex: 1 1 calc(50% - .2rem); min-width: 0; justify-content: center; text-align: center; white-space: normal; }

/* Sección de recordatorio en el panel lateral (intervalo rápido tipo nota) */
.cal-rem-box .cal-rem-quick { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .5rem; }
.cal-rem-nums, .cal-rem-units { display: flex; gap: .25rem; }
.cal-rem-n, .cal-rem-u {
    min-width: 30px; height: 30px; padding: 0 .5rem; border: 1px solid var(--color-border);
    background: var(--color-surface); border-radius: 8px; font-size: .82rem; font-weight: 700;
    color: var(--color-text); cursor: pointer; transition: background .1s, color .1s, border-color .1s;
}
.cal-rem-n:hover, .cal-rem-u:hover { border-color: var(--color-primary); }
.cal-rem-n.active, .cal-rem-u.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.cal-rem-field { display: block; font-size: .74rem; color: var(--color-text-muted); margin-bottom: .5rem; }
.cal-rem-field .form-input { margin-top: .2rem; }
.cal-rem-note { width: 100%; margin-bottom: .5rem; }
.cal-rem-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.cal-rem-msg { font-size: .78rem; margin: .5rem 0 0; }
.cal-rem-msg--ok { color: var(--color-success, #16a34a); }
.cal-rem-msg--err { color: var(--color-danger, #ef4444); }
@media (max-width: 960px) {
    .cal-layout { flex-direction: column; }
    .cal-side-panel { width: 100%; position: relative; top: 0; }
}
.cal-hint-link { font-size: .76rem; color: var(--color-primary); text-decoration: none; display: inline-block; margin-top: .35rem; }
.cal-hint-link:hover { text-decoration: underline; }
.cal-patient-pick { position: relative; }
.cal-patient-results { position: absolute; left: 0; right: 0; top: 100%; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px; box-shadow: var(--shadow-md); z-index: 5; max-height: 220px; overflow-y: auto; margin-top: 2px; }
.cal-patient-row { padding: .5rem .65rem; cursor: pointer; font-size: .85rem; }
.cal-patient-row:hover { background: color-mix(in srgb, var(--color-primary) 8%, transparent); }
.cal-patient-row small { color: var(--color-text-muted); margin-left: .35rem; }
.cal-patient-chosen { display: flex; align-items: center; gap: .5rem; padding: .5rem .65rem; background: color-mix(in srgb, var(--color-primary) 8%, transparent); border-radius: 8px; font-weight: 600; margin-top: .4rem; }
/* Sin esto el display:flex le gana al atributo hidden y la caja se ve siempre vacía. */
.cal-patient-chosen[hidden] { display: none; }
.cal-patient-notes { margin-top: .5rem; padding: .55rem .65rem; background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 8px; font-size: .88rem; }
.cal-view-row { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--color-border); font-size: .88rem; }
.cal-view-row .cvl { color: var(--color-text-muted); }
@media (max-width: 560px) { .cal-form-row { grid-template-columns: 1fr; } }

/* --- PRINT --- */
@media print {
    .sidebar, .topbar, .sidebar-overlay, .flash, .admin-footer { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .main-content { padding: 0 !important; max-width: 100% !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .btn { display: none !important; }
}

/* Banner de paquetes del paciente (formulario de cita y modal de agenda) */
.package-banner { margin-bottom: 1rem; padding: 1rem 1.15rem; border: 1.5px solid #b45309; border-radius: var(--radius-md, 8px); background: #fffbeb; }
.package-banner h4 { margin: 0 0 .35rem; color: #92400e; font-size: 1rem; display: flex; align-items: center; gap: .4rem; }
.package-banner .pkg-block { margin-top: .6rem; }
.package-banner .pkg-name { font-weight: 600; font-size: .9rem; color: #78350f; margin-bottom: .35rem; }
.pkg-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.pkg-chip { padding: .45rem .8rem; border: 1.5px solid #d97706; border-radius: 999px; background: #fff; color: #92400e; font-size: .82rem; font-weight: 500; cursor: pointer; transition: all var(--transition, .15s); }
.pkg-chip:hover { background: #fef3c7; }
.pkg-chip.selected { background: #d97706; color: #fff; border-color: #b45309; }
.pkg-chip .pkg-remaining { font-size: .72rem; opacity: .85; }
.pkg-actions { margin-top: .6rem; font-size: .82rem; }
.pkg-actions a { color: #92400e; cursor: pointer; text-decoration: underline; }
