/* --- LAYOUT PRINCIPAL EQUIPO --- */
.team-container {
    display: flex;
    height: calc(100vh - 70px);
    background: #f4f6f8;
    overflow: hidden;
    font-family: 'Montserrat', sans-serif;
}

/* --- SIDEBAR --- */
/* --- SIDEBAR --- */
.team-sidebar {
    width: 60px;
    /* Mini Sidebar */
    background: white;
    border-right: 1px solid #e1e4e8;
    display: flex;
    flex-direction: column;
    padding: 15px 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
    z-index: 10;
    align-items: center;
}

.team-menu-label {
    display: none;
    /* Hide labels */
}

/* [STANDARDIZED] Styles moved to pos_global.css (.cheesy-sidebar-item)
.team-menu-item {
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    color: #555;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: none;
    margin-bottom: 10px;
}

.team-menu-item span {
    display: none;
}

.team-menu-item:hover {
    background: #f8f9fa;
    color: #5e1c26;
}

.team-menu-item.active {
    background: #fff5f5;
    color: #5e1c26;
    font-weight: 700;
}
*/

/* --- ÁREA PRINCIPAL --- */
.team-main {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* --- BANNER EMPLEADO DEL MES --- */
.eom-banner {
    background: linear-gradient(135deg, #5e1c26 0%, #8e2de2 100%);
    border-radius: 16px;
    color: white;
    padding: 30px;
    margin-bottom: 35px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(94, 28, 38, 0.25);
}

.eom-banner::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgdmlld0JveD0iMCAwIDQwIDQwIiBvcGFjaXR5PSIwLjEiPjxwYXRoIGQ9Ik0yMCAyMGwtMjAtMjBoNDBMMjAgMjB6IiBmaWxsPSIjZmZmIi8+PC9zdmc+');
    opacity: 0.1;
}

.eom-medal {
    font-size: 60px;
    color: #ffd700;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    animation: floatMedal 3s ease-in-out infinite;
}

@keyframes floatMedal {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* --- GRID Y TARJETAS --- */
.role-section {
    margin-bottom: 40px;
    animation: fadeInUp 0.5s ease;
}

.team-grid-staggered {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.member-card-smart {
    background: white;
    border-radius: 16px;
    padding: 22px;
    border: 1px solid #edf2f7;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.01);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.member-card-smart:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
    border-color: transparent;
}

.member-card-smart::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--role-color, #ccc);
    opacity: 0;
    transition: 0.3s;
}

.member-card-smart:hover::before {
    opacity: 1;
}

.card-smart-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.card-smart-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--role-color, #ccc);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.card-smart-name {
    font-weight: 700;
    color: #2c3e50;
    font-size: 15px;
    margin-bottom: 3px;
}

.card-smart-role {
    font-size: 10px;
    text-transform: uppercase;
    color: #95a5a6;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.card-smart-stats {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-top: 18px;
    border-top: 1px solid #f7f9fc;
}

.stat-group-mini {
    text-align: left;
}

.stat-label-mini {
    font-size: 10px;
    text-transform: uppercase;
    color: #a0aec0;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-value-mini {
    font-size: 16px;
    font-weight: 800;
    color: #2d3748;
}

.sales-progress-container {
    flex: 1;
    margin-left: 25px;
    text-align: right;
}

.sales-progress-bar-bg {
    height: 8px;
    background: #edf2f7;
    border-radius: 20px;
    overflow: hidden;
    margin-top: 8px;
}

.sales-progress-bar-fill {
    height: 100%;
    border-radius: 20px;
    background: var(--role-color, #27ae60);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: width 1s ease-out;
}

/* --- PERFIL HEADER --- */
.perf-header-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 15px 25px;
    border-radius: 16px;
    margin-bottom: 25px;
    border: 1px solid #edf2f7;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    gap: 20px;
}

.perf-left-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.perf-right-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-select-wrapper {
    position: relative;
    max-width: 300px;
    flex: 1;
}

.user-select-wrapper select {
    width: 100%;
    padding: 10px 15px;
    border-radius: 10px;
    border: 2px solid #edf2f7;
    font-weight: 700;
    color: #2d3748;
    font-size: 15px;
    appearance: none;
    background: #f8fafc;
    cursor: pointer;
    transition: 0.2s;
    font-family: 'Montserrat', sans-serif;
}

.user-select-wrapper select:focus {
    border-color: #5e1c26;
    background: white;
    outline: none;
}

/* Action Buttons Standardized */
.btn-action-animated {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    height: 40px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: white;
    border: 1px solid #e1e4e8;
    color: #4a5568;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.btn-action-animated:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e0;
    color: #2d3748;
}

.btn-action-animated i {
    margin-right: 8px;
    font-size: 14px;
    color: #718096;
}

.btn-action-animated:hover i {
    color: #5e1c26;
}

.btn-liquidate {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
    padding: 0 16px;
    height: 40px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 4px rgba(197, 48, 48, 0.1);
}

.btn-liquidate:hover {
    background: #c53030;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(197, 48, 48, 0.3);
}

/* Animaciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.perf-card {
    animation: fadeInUp 0.4s ease;
}

.log-toggle-container {
    display: flex;
    background: #f7fafc;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 1px solid #edf2f7;
}

.log-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    color: #a0aec0;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.log-tab-btn.active {
    background: white;
    color: #2d3748;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.log-icon {
    margin-right: 6px;
}

.tab-log-btn {
    border: none;
    background: transparent;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-log-btn.active {
    background: white;
    color: #5e1c26;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.tab-log-btn:hover:not(.active) {
    color: #64748b;
}

.audit-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
    transition: 0.1s;
}

.audit-row:hover {
    background: #f8fafc;
}

.audit-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #eee;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 14px;
    flex-shrink: 0;
}

/* Modales Team */
.benefit-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    align-items: center;
}

.btn-mini-add {
    background: #edf2f7;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    color: #27ae60;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-mini-add:hover {
    background: #27ae60;
    color: white;
}

.pin-btn {
    background: white;
    border: 1px solid #ddd;
    padding: 15px;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.1s;
    font-weight: bold;
    color: #333;
}

.pin-btn:active {
    transform: scale(0.95);
    background: #eee;
}

/* Scrollbar fina */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* --- ESTILOS MIGRADOS DE JS (TEAM UI) --- */

/* EOM Banner */
.eom-label {
    font-size: 12px;
    opacity: 0.8;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.eom-name {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
}

.eom-stats {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 5px;
}

/* Team Grid */
.role-header {
    border-bottom: 2px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 15px;
    font-weight: 800;
    color: #333;
    display: flex;
    align-items: center;
}

.role-dot {
    width: 6px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
    margin-right: 10px;
}

.role-count {
    font-size: 11px;
    color: #999;
    background: #eee;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.team-empty-state {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* Smart Card */
.stat-highlight {
    font-weight: bold;
}

/* Logs Table */
.logs-empty {
    text-align: center;
    padding: 30px;
    color: #ccc;
}

.logs-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}

.logs-thead {
    background: #f8fafc;
    color: #64748b;
}

.logs-table {
    width: 100% !important;
    border-collapse: collapse !important;
    display: table !important;
}

.logs-th {
    padding: 8px;
    text-align: left;
    color: #5e1c26;
    font-weight: bold;
    border-bottom: 2px solid #5e1c26;
}

.logs-row {
    border-bottom: 1px solid #eee;
}

.logs-td {
    padding: 8px;
}

.text-center {
    text-align: center;
}

.text-green {
    color: #27ae60;
}

.text-red {
    color: #c0392b;
}

/* Kiosk */
.kiosk-empty {
    grid-column: 1/-1;
    text-align: center;
    color: white;
    font-size: 16px;
    opacity: 0.8;
}

.kiosk-card {
    background: white;
    border-radius: 12px;
    padding: 12px 15px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s;
    border-left: 5px solid;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.kiosk-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f4f6f8;
    flex-shrink: 0;
}

.kiosk-name {
    font-weight: 800;
    color: #2c3e50;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kiosk-role {
    font-size: 10px;
    color: #95a5a6;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.kiosk-status-icon {
    font-size: 18px;
}

.kiosk-status-text {
    font-weight: 800;
    font-size: 9px;
    margin-top: 3px;
    letter-spacing: 0.5px;
}

/* Clock Status */
.status-working {
    color: #27ae60;
    font-weight: bold;
}

.status-off {
    color: #a0aec0;
    font-weight: bold;
}

/* Pin Modal */
.pin-modal-content {
    width: 320px;
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.pin-title {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.pin-action {
    font-size: 12px;
    font-weight: bold;
    margin-top: 5px;
    letter-spacing: 1px;
}

.pin-input-wrapper {
    margin: 20px 0;
    position: relative;
}

.pin-input {
    width: 100%;
    height: 50px;
    font-size: 30px;
    text-align: center;
    border: 2px solid #eee;
    border-radius: 12px;
    outline: none;
    letter-spacing: 10px;
    color: #333;
}

.pin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.pin-btn-num {
    height: 60px;
    font-size: 20px;
    font-weight: bold;
    background: #f8f9fa;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #333;
    transition: background 0.2s;
}

.pin-btn-del {
    height: 60px;
    font-size: 18px;
    background: #ffebee;
    color: #c0392b;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

.pin-btn-submit {
    height: 60px;
    font-size: 20px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

.pin-btn-cancel {
    background: none;
    border: none;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
}

/* Log Actions */
.btn-log-action {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 8px 15px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

@media (max-width: 768px) {
    .btn-log-action .btn-text {
        display: none;
    }

    .btn-log-action {
        padding: 8px 10px;
        /* Adjust padding for square-ish icon */
    }
}

/* Sales Metrics */
.sales-empty {
    text-align: center;
    color: #ccc;
    font-size: 11px;
    padding: 10px;
}

/* --- RESPONSIVE TEAM (TABLET & MOBILE) --- */

/* Mobile/Tablet (Portrait & Landscape) */
@media (max-width: 1024px) {

    /* Layout Reset - Keep Sidebar + Main Side-by-Side */
    .team-container {
        flex-direction: row !important;
        /* Force Row */
        height: calc(100vh - 60px) !important;
        /* Fixed height for internal scroll */
        min-height: 0 !important;
        padding-bottom: 0 !important;
        width: 100vw !important;
        /* Ensure container fits viewport */
        overflow: hidden !important;
        /* Prevent body scroll */
    }

    /* Restore Sidebar (Mini) - Reduced width slightly */
    .team-sidebar {
        display: flex !important;
        flex-direction: column !important;
        width: 45px !important;
        /* Slimmer Sidebar */
        min-width: 45px !important;
        height: 100% !important;
        border-right: 1px solid #e1e4e8 !important;
        border-top: none !important;
        justify-content: flex-start !important;
        padding: 10px 0 !important;
        z-index: 9999 !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05) !important;
        position: relative !important;
    }

    .team-menu-item {
        width: 100% !important;
        height: 40px !important;
        margin-bottom: 10px !important;
        border-radius: 0 !important;
        flex: 0 0 auto !important;
    }

    /* Main Area - CRITICAL FIX for overflow */
    .team-main {
        flex: 1 !important;
        min-width: 0 !important;
        /* Allows flex child to shrink below content size */
        width: 0 !important;
        /* Forces width calculation based on flex grow */
        padding: 10px 5px !important;
        /* Minimal padding */
        overflow-y: auto !important;
        /* Internal Scroll */
        -webkit-overflow-scrolling: touch !important;
    }

    /* Grid 1 Column (User Request) */
    .team-grid-staggered {
        display: grid !important;
        grid-template-columns: 100% !important;
        /* Strict 1 column */
        gap: 15px !important;
    }

    /* EOM Banner */
    .eom-banner {
        padding: 15px !important;
        min-height: auto !important;
        flex-direction: column !important;
        /* Stack vertically on mobile */
        text-align: center !important;
    }

    .eom-medal {
        font-size: 30px !important;
        margin-bottom: 5px !important;
    }

    .eom-name {
        font-size: 16px !important;
    }

    /* Performance Header (Profile) - Harmonious Grid */
    .perf-header-controls {
        display: grid !important;
        grid-template-columns: repeat(12, 1fr) !important;
        gap: 10px !important;
        padding: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    /* Unwrap groups to place children directly in main grid */
    .perf-left-group,
    .perf-right-group {
        display: contents !important;
    }

    /* 1. Back Button (Span 2 - approx 15%) */
    .perf-left-group>button {
        grid-column: span 2 !important;
        width: 100% !important;
        justify-content: center !important;
    }

    /* 2. Employee Select (Span 10 - approx 85%) */
    .user-select-wrapper {
        grid-column: span 10 !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* 3. Pin Toggle (Span 2) */
    .perf-left-group>div:nth-child(3) {
        grid-column: span 2 !important;
        margin: 0 !important;
        /* Reset margin-left inline */
        justify-content: center !important;
    }

    /* Ensure Pin button fills cell */
    #btn-toggle-pin {
        width: 100% !important;
    }

    /* 4. Role Badge (Span 10) */
    #perf-role-badge {
        grid-column: span 10 !important;
        align-self: center !important;
        justify-self: start !important;
        width: 100% !important;
        text-align: center !important;
    }

    /* 5. Expediente & Editar (Span 6 each - 50/50) */
    .btn-action-animated {
        grid-column: span 6 !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* 6. Liquidate (Span 12 - Full Width) */
    .btn-liquidate {
        grid-column: span 12 !important;
        width: 100% !important;
        margin-top: 5px !important;
    }

    /* --- PROFILE CONTENT REORDERING (Mobile Only) --- */
    /* 1. Header (Already Top) */

    /* Unwrap Columns to enforce global order */
    .perf-content-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding: 0 !important;
        gap: 20px !important;
    }

    .perf-col-left,
    .perf-col-right {
        display: contents !important;
        /* Unwrap contents to parents */
    }

    /* 2. Payroll (Nómina) */
    #payroll-panel {
        order: 1 !important;
        width: 100% !important;
    }

    /* 3. Sales Trend (Chart) */
    .perf-col-left .perf-card:nth-child(1) {
        order: 2 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 300px !important;
    }

    /* 4. Last Tickets (Table) */
    .perf-col-left .perf-card:nth-child(2) {
        order: 3 !important;
        width: 100% !important;
    }

    /* 5. Logs */
    .perf-col-right .perf-card:last-child {
        order: 4 !important;
        width: 100% !important;
    }

    /* Fix Logs Header Switch */
    .perf-card .tab-log-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    /* Ensure header wraps if tight */
    .perf-card>div:first-child {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    /* Generic Card Styles for Mobile */
    .perf-card {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* Ensure charts resize */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    .perf-card .table-responsive,
    .perf-card table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
    }

    /* FIX: Force Logs Table to maintain table layout and full width */
    .perf-card table.logs-table {
        display: table !important;
        white-space: normal !important;
        /* Allow text wrap if needed */
    }

    /* Statistics Cards (Payroll) to fit */
    .stat-card-row {
        flex-direction: column !important;
        /* Stack stats vertically */
        gap: 10px !important;
        width: 100% !important;
    }

    .stat-card {
        width: 100% !important;
        min-width: 0 !important;
        /* Allow shrinking */
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    /* Modal Pin Pad */
    .pin-modal-content {
        width: 95% !important;
        max-width: 300px !important;
        padding: 15px !important;
    }

    /* --- SHIFT MANAGER REORDERING (Mobile) --- */
    #shifts-view {
        overflow-y: auto !important;
        /* Enable page scroll */
        height: calc(100vh - 60px) !important;
        /* display: flex !important; REMOVED */
        flex-direction: column !important;
        padding: 10px !important;
    }

    /* Unwrap all parents to flat list for reordering */
    .shift-header,
    .shift-controls,
    .shift-content-body,
    .shift-sidebar-panel {
        display: contents !important;
    }

    /* Hide Title & Separator (User requested specific order starting with tools) */
    .shift-title,
    .shift-separator {
        display: none !important;
    }

    /* 1. Herramientas (Week Nav) */
    .shift-tools {
        order: 1 !important;
        width: 100% !important;
        justify-content: center !important;
        margin-bottom: 10px !important;
        background: white !important;
        padding: 10px !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
    }

    /* 2. Botones de añadir y copiar */
    .shift-actions {
        order: 2 !important;
        width: 100% !important;
        justify-content: space-between !important;
        /* Spread buttons */
        margin-bottom: 15px !important;
    }

    .shift-actions button {
        flex: 1 !important;
        justify-content: center !important;
    }

    /* 3. Calendario */
    .shift-grid-panel {
        order: 3 !important;
        width: 100% !important;
        min-height: 400px !important;
        /* Ensure visibility */
        margin-bottom: 20px !important;
        flex: none !important;
        /* Disable flex grow/shrink issues */
        overflow-x: auto !important;
        /* ENABLE LATERAL SCROLL */
    }

    /* Force grid to be wide enough to scroll */
    .shift-grid-panel>div {
        min-width: 800px !important;
    }

    /* 4. Carga de Trabajo */
    .shift-workload-card {
        order: 4 !important;
        width: 100% !important;
        min-height: 200px !important;
        margin-bottom: 15px !important;
        flex: none !important;
    }

    /* 5. Nómina Calculada */
    .shift-payroll-card {
        order: 5 !important;
        width: 100% !important;
        margin-bottom: 20px !important;
        flex: none !important;
    }
}



.status-ok {
    color: #27ae60;
}

/* Benefits Modal */
.alert-box-warning {
    background: #fff3cd;
    color: #856404;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 15px;
    border: 1px solid #ffeeba;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- GLOBAL PIN TOOLTIP STYLES (Desktop + Responsive) --- */
#btn-toggle-pin {
    position: relative;
    /* Anchor for tooltip */
}

/* Tooltip Body */
#btn-toggle-pin::after {
    content: attr(data-pin);
    position: absolute;
    bottom: 125%;
    /* Above button */
    left: 50%;
    transform: translateX(-50%);
    background: #2d3748;
    color: white;
    padding: 5px 12px;
    border-radius: 6px;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    letter-spacing: 1px;
    font-weight: 700;
    opacity: 0;
    visibility: hidden;
    transition: 0.2s ease;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Tooltip Arrow */
#btn-toggle-pin::before {
    content: '';
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2d3748;
    opacity: 0;
    visibility: hidden;
    transition: 0.2s ease;
    z-index: 100;
}

/* Active State */
#btn-toggle-pin.show-pin-tooltip::after {
    opacity: 1;
    visibility: visible;
    bottom: 135%;
    /* Animation Up */
}

#btn-toggle-pin.show-pin-tooltip::before {
    opacity: 1;
    visibility: visible;
    bottom: 115%;
    /* Animation Up */
}

/* Hide legacy display area globally */
#pin-display-area {
    display: none !important;
}

/* --- TABLET SPECIFIC OVERRIDE (User Request: Desktop-like Grid) --- */
@media (min-width: 768px) and (max-width: 1024px) {
    .team-grid-staggered {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
        gap: 20px !important;
    }

    /* Ensure cards are compact enough for tablet grid */
    .member-card-smart {
        padding: 15px !important;
    }

    .card-smart-avatar {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }

    .card-smart-name {
        font-size: 13px !important;
    }

    /* --- DASHBOARD GRID RE-LAYOUT (Tickets Left / Logs Right) --- */
    /* MOVED HERE to apply ONLY to Tablets (768px - 1024px) */
    .perf-content-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
        align-items: start !important;
    }

    /* Unwrap columns to treat cards as direct grid items */
    .perf-col-left,
    .perf-col-right {
        display: contents !important;
    }

    /* 1. Trends Chart (Row 1, Col 1) */
    .perf-col-left>.perf-card:nth-child(1) {
        grid-column: 1 !important;
        grid-row: 1 !important;
        margin: 0 !important;
        height: auto !important;
    }

    /* 2. Payroll Panel (Row 1, Col 2) */
    .perf-col-right>#payroll-panel {
        grid-column: 2 !important;
        grid-row: 1 !important;
        margin: 0 !important;
        height: 100% !important;
    }

    /* 3. Latest Tickets (Row 2, Col 1) */
    .perf-col-left>.perf-card:nth-child(2) {
        grid-column: 1 !important;
        grid-row: 2 !important;
        margin: 0 !important;
        height: 500px !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Make table scrollable inside fixed height */
    .perf-col-left>.perf-card:nth-child(2)>div:last-child {
        flex: 1 !important;
        overflow-y: auto !important;
    }

    /* 4. Logs Panel (Row 2, Col 2) */
    .perf-col-right>.perf-card:last-child {
        grid-column: 2 !important;
        grid-row: 2 !important;
        margin: 0 !important;
        height: 500px !important;
    }

    /* Font Adjustments for Tablet Density */
    .table-responsive,
    table {
        font-size: 11px !important;
    }

    th,
    td {
        padding: 6px 8px !important;
    }
}

/* --- PROFILE HEADER RESPONSIVE OVERRIDE (Tablet & Mobile) --- */
@media (max-width: 1366px) {
    .perf-header-controls {
        display: grid !important;
        grid-template-columns: repeat(12, 1fr) !important;
        grid-auto-rows: min-content !important;
        gap: 8px !important;
        padding: 10px !important;
        height: auto !important;
        align-items: center !important;
        /* Global Vertical Center */
        width: 100% !important;
    }

    /* Unwrap Groups */
    .perf-left-group,
    .perf-right-group {
        display: contents !important;
    }

    /* 1. Badge (Top, Small, Centered) */
    #perf-role-badge {
        grid-column: 1 / -1 !important;
        order: 1 !important;
        width: fit-content !important;
        justify-self: center !important;
        font-size: 9px !important;
        padding: 4px 10px !important;
        margin-bottom: 5px !important;
        height: auto !important;
        align-self: center !important;
    }

    /* 2. Controls Row (Back - Name - Pin) */
    /* ALIGNMENT FIX: Match Line 3 (3 columns of span 4) */

    .perf-left-group>button {
        /* Back Button */
        grid-column: span 4 !important;
        order: 2 !important;
        width: 42px !important;
        height: 40px !important;
        align-self: center !important;
        justify-self: end !important;
        /* Push to center */
        margin-right: 5px !important;
    }

    .user-select-wrapper {
        /* Name Select */
        grid-column: span 4 !important;
        order: 2 !important;
        margin: 0 !important;
        align-self: center !important;
        width: 100% !important;
    }

    .user-select-wrapper select {
        text-align: center !important;
        text-align-last: center !important;
    }

    .perf-left-group>div:nth-child(3) {
        /* Pin Toggle Wrapper */
        grid-column: span 4 !important;
        order: 2 !important;
        justify-content: start !important;
        /* Push to center */
        margin: 0 !important;
        align-self: center !important;
        display: flex !important;
        margin-left: 5px !important;
    }

    #btn-toggle-pin {
        width: 42px !important;
        height: 40px !important;
    }

    /* 3. Actions Row (Icons Only) */
    .perf-right-group>button {
        order: 3 !important;
        font-size: 0 !important;
        /* Hide Text */
        padding: 0 !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
    }

    /* Distribute 3 buttons across 12 cols (4 cols each) */
    .perf-right-group>button:nth-child(2) {
        grid-column: span 4 !important;
    }

    /* Expediente */
    .perf-right-group>button:nth-child(3) {
        grid-column: span 4 !important;
    }

    /* Editar */
    .perf-right-group>button:nth-child(4) {
        grid-column: span 4 !important;
    }

    /* Liquidar */

    /* Force Icons Visible and Sized */
    .perf-right-group>button i {
        font-size: 16px !important;
        margin: 0 !important;
    }
}