/* ============================================
   ControlMax ERP - Sistema de Diseño Unificado
   "Clean & Corporate Premium"
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #0f172a;
    --secondary-light: #1e293b;
    --secondary-muted: #334155;
    
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --success-border: #a7f3d0;
    
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-border: #fca5a5;
    
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-border: #fcd34d;
    
    --info: #06b6d4;
    --info-light: #ecfeff;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --radius: 16px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================
   RESET & BASE
   ============================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    display: flex;
    height: 100vh;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
    width: 270px;
    min-width: 270px;
    background: linear-gradient(180deg, var(--secondary) 0%, var(--secondary-light) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
    border-right: 1px solid var(--secondary-muted);
    transition: width var(--transition);
}

.brand {
    padding: 22px 24px;
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
    color: white;
    border-bottom: 1px solid var(--secondary-muted);
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.brand i {
    color: #38bdf8;
    font-size: 26px;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.nav-menu {
    padding: 16px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    padding: 13px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #94a3b8;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 14px;
    font-weight: 600;
    border-left: 4px solid transparent;
    white-space: nowrap;
}

.nav-item i {
    font-size: 17px;
    width: 22px;
    text-align: center;
    transition: transform var(--transition);
}

.nav-item:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item:hover i {
    transform: scale(1.1);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.15) 0%, rgba(37, 99, 235, 0.02) 100%);
    color: #60a5fa;
    border-left-color: var(--primary);
    font-weight: 700;
}

.nav-item.active i {
    color: #60a5fa;
}

/* ============================
   MAIN LAYOUT
   ============================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.header {
    height: 64px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    flex-shrink: 0;
}

.header-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.header-user img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--primary-light);
    object-fit: cover;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}

/* ============================
   TABS & ANIMATIONS
   ============================ */
.tab-pane {
    display: none;
    animation: fadeIn var(--transition-slow);
}

.tab-pane.active {
    display: block;
}

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

/* ============================
   TYPOGRAPHY
   ============================ */
.page-title {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 800;
    color: var(--secondary-light);
    margin-bottom: 24px;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================
   CARDS
   ============================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

/* ============================
   METRICS GRID
   ============================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    padding: 18px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    border-left: 5px solid var(--primary);
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.metric-info h4 {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 700;
}

.metric-info h2 {
    font-family: var(--font-heading);
    font-size: 24px;
    color: var(--text-main);
    font-weight: 800;
}

/* ============================
   CONTROLS BAR
   ============================ */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: 14px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 11px 14px 11px 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    transition: all var(--transition);
    background: var(--bg-body);
    font-weight: 500;
    font-family: var(--font-body);
}

.search-box input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================
   BUTTONS (Unified)
   ============================ */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
    font-family: var(--font-body);
    white-space: nowrap;
    text-decoration: none;
}

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

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--secondary-light);
}

.btn-outline:hover {
    background: var(--bg-body);
    border-color: var(--text-light);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* ============================
   TABLES
   ============================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: white;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: #f8fafc;
    padding: 14px 18px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 13px;
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.user-info strong {
    display: block;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
}

.user-info span {
    color: var(--text-muted);
    font-size: 11px;
}

/* ============================
   BADGES
   ============================ */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.bg-success { background: var(--success-light); color: #047857; border: 1px solid var(--success-border); }
.bg-danger { background: var(--danger-light); color: #b91c1c; border: 1px solid var(--danger-border); }
.bg-warning { background: var(--warning-light); color: #b45309; border: 1px solid var(--warning-border); }
.bg-secondary { background: #e2e8f0; color: #475569; border: 1px solid #cbd5e1; }

.hidden-until-search {
    display: none;
}

/* ============================
   MODALS (Unified, Proportional)
   ============================ */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 16px;
}

.modal-backdrop.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 760px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.modal-backdrop.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    color: var(--secondary-light);
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-light);
    cursor: pointer;
    transition: color var(--transition);
    padding: 4px;
}

.btn-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
    border-radius: 0 0 16px 16px;
    position: sticky;
    bottom: 0;
    z-index: 10;
    flex-shrink: 0;
}

/* ============================
   FORMS (Unified)
   ============================ */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: span 2;
}

.form-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--secondary-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all var(--transition);
    background: var(--bg-body);
    font-weight: 500;
    font-family: var(--font-body);
}

.form-input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-light);
    outline: none;
}

select.form-input {
    cursor: pointer;
    appearance: auto;
}

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

/* ============================
   SWITCH TOGGLE
   ============================ */
.switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    justify-content: space-between;
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: var(--transition-slow);
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-slow);
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* ============================
   ALERTS
   ============================ */
.alert-item {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    border-left: 5px solid;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alert-danger {
    background: var(--danger-light);
    border: 1px solid var(--danger-border);
    border-left-width: 5px;
    border-left-color: var(--danger);
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-light);
    border: 1px solid var(--warning-border);
    border-left-width: 5px;
    border-left-color: var(--warning);
    color: #92400e;
}

.alert-success {
    background: var(--success-light);
    border: 1px solid var(--success-border);
    border-left-width: 5px;
    border-left-color: var(--success);
    color: #065f46;
}

.alert-info {
    background: var(--info-light);
    border: 1px solid #cffafe;
    border-left-width: 5px;
    border-left-color: var(--info);
    color: #155e75;
}

/* ============================
   EXPEDIENTE DIGITAL / TIMELINE
   ============================ */
.expediente-timeline {
    position: relative;
    padding-left: 24px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 16px;
}

.timeline-item {
    position: relative;
    transition: transform var(--transition), opacity var(--transition);
}

.timeline-item:hover {
    transform: translateX(4px);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -31px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transition: all var(--transition);
}

.timeline-item:hover::before {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.2);
}

.timeline-date {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
}

.timeline-content {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-main);
    font-weight: 500;
}

/* ============================
   CONTRATOS DETALLE
   ============================ */
.detail-header {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 12px;
}

.detail-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.detail-title h2 {
    font-size: 22px;
    color: var(--secondary);
    font-weight: 800;
    font-family: var(--font-heading);
}

.detail-id {
    color: var(--primary);
    font-family: monospace;
    font-weight: bold;
    background: var(--primary-light);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    margin-bottom: 24px;
}

.info-list {
    list-style: none;
}

.info-list li {
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-list li:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
}

.metrics-mini {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.metric-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: var(--radius-md);
    text-align: center;
}

.metric-box h4 {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    font-weight: 700;
}

.metric-box h2 {
    font-family: var(--font-heading);
    font-size: 26px;
    color: var(--secondary);
    font-weight: 800;
}

/* ============================
   CONTRATOS - TRABAJADORES ASOCIADOS
   ============================ */
.asociados-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 18px;
    background: #f8fafc;
}

.asociado-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.asociado-item:last-child {
    margin-bottom: 0;
}

/* ============================
   PDF PREVIEW
   ============================ */
.pdf-preview-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    height: 320px;
    background: #eaeaea;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.pdf-preview-box embed, .pdf-preview-box iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.pdf-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

/* ============================
   EXPEDIENTE GRID
   ============================ */
.expediente-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    margin-bottom: 24px;
    align-items: start;
}

/* ============================
   SPA VIEWS
   ============================ */
.vista {
    display: none;
}
.vista.active {
    display: block;
}

/* ============================
   PRINT STYLES
   ============================ */
@media print {
    body * {
        visibility: hidden;
    }
    #trabajadores-detalle-view, #trabajadores-detalle-view * {
        visibility: visible;
    }
    #trabajadores-detalle-view {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
    }
    .controls-bar {
        display: none !important;
    }
}

/* ============================
   COMPLIANCE BADGES (Table Row)
   ============================ */
.compliance-checklist {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.comp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
    transition: all var(--transition);
    cursor: default;
    border: 1px solid transparent;
}

.comp-badge i {
    font-size: 9px;
}

.comp-badge.status-loaded {
    background: #d1fae5;
    color: #065f46;
    border-color: #a7f3d0;
}

.comp-badge.status-missing {
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
}

.comp-badge.status-expiring {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
    animation: pulse-yellow 2s infinite alternate;
}

.comp-badge.status-expired {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
    animation: pulse-red 2s infinite alternate;
}

@keyframes pulse-yellow {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    100% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    100% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* ============================
   COMPLIANCE CONTROL PANEL
   ============================ */
.compliance-control-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.compliance-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.comp-stat-card {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--transition);
}

.comp-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.comp-stat-card .icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.comp-stat-card.stat-total .icon { background: var(--primary-light); color: var(--primary); }
.comp-stat-card.stat-complete .icon { background: var(--success-light); color: var(--success); }
.comp-stat-card.stat-incomplete .icon { background: #f1f5f9; color: #64748b; }
.comp-stat-card.stat-alerts .icon { background: var(--warning-light); color: var(--warning); }

.comp-stat-card .info {
    display: flex;
    flex-direction: column;
}

.comp-stat-card .info span {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.comp-stat-card .info h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filters-row .search-box {
    flex: 1;
    min-width: 200px;
}

.filters-row select {
    width: auto;
    min-width: 130px;
}

/* ============================
   RESPONSIVE: TABLETS (max-width: 1200px)
   ============================ */
@media (max-width: 1200px) {
    .sidebar {
        width: 240px;
        min-width: 240px;
    }

    .brand {
        padding: 16px 18px;
        font-size: 19px;
    }

    .nav-item {
        padding: 11px 18px;
        font-size: 13px;
        gap: 10px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .expediente-grid {
        grid-template-columns: 1fr;
    }

    .asociado-item {
        grid-template-columns: 2fr 1fr 1fr auto;
    }

    .metrics-mini {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================
   RESPONSIVE: TABLETS / MOBILE LANDSCAPE (max-width: 1024px)
   ============================ */
@media (max-width: 1024px) {
    .content-area {
        padding: 20px;
    }

    .filters-row {
        flex-wrap: wrap;
    }

    .filters-row .search-box {
        min-width: 100%;
    }

    .header {
        padding: 0 20px;
    }

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

/* ============================
   RESPONSIVE: MOBILE (max-width: 768px)
   ============================ */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }

    /* Sidebar → Horizontal Nav */
    .sidebar {
        width: 100% !important;
        min-width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--secondary-muted);
        flex-direction: column;
    }

    .brand {
        padding: 12px 16px;
        font-size: 17px;
        justify-content: center;
    }

    .nav-menu {
        display: flex;
        flex-direction: row;
        padding: 6px 10px;
        overflow-x: auto;
        white-space: nowrap;
        gap: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        padding: 8px 14px;
        font-size: 12px;
        border-left: none;
        border-radius: var(--radius-sm);
        gap: 6px;
        flex-shrink: 0;
    }

    .nav-item.active {
        border-left: none;
        background: rgba(37, 99, 235, 0.2);
    }

    /* Main Content */
    .main-content {
        height: auto;
        min-height: 0;
        flex: 1;
    }

    .header {
        padding: 0 14px;
        height: 52px;
    }

    .header-title {
        font-size: 15px;
    }

    .content-area {
        padding: 14px;
    }

    /* Metrics */
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .metric-card {
        padding: 14px;
        gap: 12px;
    }

    .metric-icon {
        width: 42px;
        height: 42px;
        font-size: 17px;
    }

    .metric-info h4 {
        font-size: 10px;
    }

    .metric-info h2 {
        font-size: 20px;
    }

    /* Modals */
    .modal-backdrop {
        padding: 10px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
        border-radius: 14px;
    }

    .modal-header {
        padding: 14px 18px;
        border-radius: 14px 14px 0 0;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    .modal-body {
        padding: 18px;
    }

    .modal-footer {
        padding: 12px 18px;
        border-radius: 0 0 14px 14px;
        flex-wrap: wrap;
    }

    /* Forms */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full {
        grid-column: span 1;
    }

    /* Tables */
    .table-container {
        border-radius: var(--radius-md);
    }

    th, td {
        padding: 10px 12px;
        font-size: 12px;
    }

    /* Detail */
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .detail-title h2 {
        font-size: 18px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .expediente-grid {
        grid-template-columns: 1fr;
    }

    .metrics-mini {
        grid-template-columns: 1fr;
    }

    .compliance-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .asociado-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Cards */
    .card {
        padding: 16px;
        border-radius: 14px;
    }

    .page-title {
        font-size: 20px;
    }

    /* Buttons full width on mobile */
    .filters-row .btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }

    .controls-bar {
        padding: 12px 14px;
        gap: 10px;
    }

    /* PDF Preview */
    .pdf-preview-box {
        height: 250px;
    }
}

/* ============================
   RESPONSIVE: SMALL PHONES (max-width: 480px)
   ============================ */
@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .metric-card {
        padding: 12px;
    }

    .header {
        height: 48px;
        padding: 0 10px;
    }

    .header-title {
        font-size: 14px;
    }

    .content-area {
        padding: 10px;
    }

    .brand {
        font-size: 15px;
        padding: 10px 12px;
    }

    .nav-item {
        padding: 6px 10px;
        font-size: 11px;
    }

    .page-title {
        font-size: 18px;
    }

    .modal-content {
        width: 98%;
        max-height: 92vh;
    }

    .modal-header h2 {
        font-size: 15px;
    }

    .modal-body {
        padding: 14px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 12px;
    }

    .compliance-stats-grid {
        grid-template-columns: 1fr;
    }

    .detail-title h2 {
        font-size: 16px;
    }

    th, td {
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* ============================
   RESPONSIVE: LARGE SCREENS (min-width: 1400px)
   ============================ */
@media (min-width: 1400px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .content-area {
        padding: 32px 40px;
    }

    .modal-content {
        max-width: 880px;
    }
}
