/* ============================================================
   CRO III Lima-Callao — Material Design 3 System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* MD3 Primary */
    --md-primary:           #7a1024;
    --md-primary-hover:     #5c0a1a;
    --md-primary-container: #fce4ec;
    --md-on-primary:        #ffffff;
    --md-on-primary-container: #4a0010;

    /* MD3 Secondary (Gold) */
    --md-secondary:         #b8860b;
    --md-secondary-container: #fff3d6;
    --md-on-secondary:      #ffffff;

    /* MD3 Tertiary */
    --md-tertiary:          #6366f1;
    --md-tertiary-container:#eef2ff;

    /* MD3 Surface */
    --md-surface:           #fffbfe;
    --md-surface-dim:       #f5f0ec;
    --md-surface-container: #f3eeea;
    --md-surface-container-low:  #f9f4f0;
    --md-surface-container-high: #ede8e4;
    --md-surface-variant:   #e7e0db;
    --md-on-surface:        #1c1917;
    --md-on-surface-variant:#57534e;

    /* MD3 Outline */
    --md-outline:           #d6d3d1;
    --md-outline-variant:   #e7e5e4;

    /* Legacy aliases (used by public registration form) */
    --primario:        #7a1024;
    --primario-hover:  #5c0a1a;
    --primario-light:  rgba(122,16,36,0.07);
    --primario-dark:   #4d0114;
    --secundario:      #b8860b;
    --secundario-claro:#d4a020;
    --verde:           #15803d;
    --rojo:            #dc2626;
    --texto:           #1c1917;
    --texto-muted:     #57534e;
    --texto-suave:     #78716c;
    --fondo:           #fafaf9;
    --fondo-calido:    #fef7ed;
    --blanco:          #ffffff;
    --linea:           #d6d3d1;
    --suave:           #fffbeb;
    --sombra:          0 1px 3px rgba(0,0,0,0.06), 0 2px 12px rgba(122,16,36,0.08);
    --sombra-hover:    0 4px 20px rgba(122,16,36,0.14);

    /* Semantic */
    --md-success:           #15803d;
    --md-success-container: #dcfce7;
    --md-error:             #dc2626;
    --md-error-container:   #fef2f2;
    --md-warning:           #d97706;
    --md-warning-container: #fef3c7;
    --md-info:              #0891b2;
    --md-info-container:    #ecfeff;

    /* Elevation */
    --md-elevation-1: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --md-elevation-2: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --md-elevation-3: 0 10px 15px rgba(0,0,0,0.07), 0 4px 6px rgba(0,0,0,0.05);
    --md-elevation-4: 0 20px 25px rgba(0,0,0,0.08), 0 8px 10px rgba(0,0,0,0.04);

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* Shape */
    --md-shape-xs: 4px;
    --md-shape-sm: 8px;
    --md-shape-md: 12px;
    --md-shape-lg: 16px;
    --md-shape-xl: 28px;
    --md-shape-full: 9999px;
}

/* ---- Base ---- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--md-surface-dim);
    min-height: 100vh;
    color: var(--md-on-surface);
    -webkit-font-smoothing: antialiased;
}

/* Material Symbols helper */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}
.material-symbols-outlined.filled {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ============================================================
   ADMIN LAYOUT — Sidebar + Topbar
   ============================================================ */

/* ============================================================
   Sidebar — MD3 Navigation Drawer
   Refs: Material Design 3 (360dp, 56dp items, active indicator)
         IBM Carbon (256px, compact items)
         Atlassian (grouped nav, no noise)
         Nielsen (7±2 items, progressive disclosure)
         Gestalt (proximity grouping, not borders/cards)
   ============================================================ */
.md-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #5a0c1a 0%, var(--md-primary) 100%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Brand: compact, logo + wordmark (Atlassian pattern) */
.md-sidebar-brand {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.md-sidebar-brand .brand-name {
    font-size: 15px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}
.md-sidebar-brand .brand-institution {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.45);
    margin-top: 1px;
}

/* Navigation area */
.md-sidebar-nav {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Primary nav items: 44px height (MD3 spec), pill shape */
.md-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 44px;
    border-radius: var(--md-shape-full);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}
.md-nav-item .material-symbols-outlined {
    font-size: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}
.md-nav-item .nav-label { flex: 1; }
.md-nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}
.md-nav-item:hover .material-symbols-outlined { opacity: 1; }

/* Active state: MD3 "active indicator" — filled pill */
.md-nav-item.active {
    background: rgba(255,255,255,0.14);
    color: white;
    font-weight: 600;
}
.md-nav-item.active .material-symbols-outlined {
    opacity: 1;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Badge: minimal count (Atlassian pattern) */
.md-nav-item .nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.9);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--md-shape-full);
    min-width: 20px;
    text-align: center;
}

/* Sub-group: progressive disclosure (Nielsen) + tree view (IBM Carbon L-shape) */
.nav-sub-group {
    margin: 2px 0 4px 18px;
    padding-left: 14px;
    border-left: 1.5px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 0;
}
.md-nav-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 34px;
    border-radius: 0 var(--md-shape-full) var(--md-shape-full) 0;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: all 0.15s ease;
    position: relative;
}
.md-nav-sub .nav-label { flex: 1; }
.md-nav-sub:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
}
.md-nav-sub.active {
    color: white;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
}
.md-nav-sub.active .nav-sub-indicator {
    position: absolute;
    left: -15px;
    width: 3px;
    height: 16px;
    background: white;
    border-radius: 0 2px 2px 0;
}
.md-nav-sub:not(.active) .nav-sub-indicator { display: none; }
.md-nav-sub .nav-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    min-width: 16px;
    text-align: center;
}
.md-nav-sub.active .nav-count { color: rgba(255,255,255,0.8); }
.md-nav-sub.locked {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* Footer: user identity row (Fitts's Law: always accessible) */
.md-sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.md-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--md-shape-sm);
    transition: background 0.15s;
}
.md-sidebar-user:hover { background: rgba(255,255,255,0.05); }
.md-sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--md-shape-full);
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.md-sidebar-user-info .user-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
    line-height: 1.3;
}
.md-sidebar-user-info .user-role {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.nav-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--md-shape-full);
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    transition: all 0.15s;
}
.nav-logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
}
.nav-logout-btn .material-symbols-outlined { font-size: 18px; }

/* Topbar */
.md-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--md-surface);
    border-bottom: 1px solid var(--md-outline-variant);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 90;
}
.md-topbar-menu {
    display: none;
    background: none;
    border: none;
    color: var(--md-on-surface);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--md-shape-full);
    transition: background 0.2s;
}
.md-topbar-menu:hover { background: var(--md-surface-container); }
.md-topbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--md-on-surface);
    flex: 1;
}
.md-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Main Content */
.md-main {
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    min-height: 100vh;
}
.md-content {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Overlay for mobile */
.md-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}
.md-overlay.active {
    display: block;
    opacity: 1;
}

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

/* ---- Cards ---- */
.md-card {
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-1);
    overflow: hidden;
}
.md-card-outlined {
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    border: 1px solid var(--md-outline-variant);
    overflow: hidden;
}
.md-card-header {
    padding: 20px 24px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.md-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--md-on-surface);
    display: flex;
    align-items: center;
    gap: 8px;
}
.md-card-header h3 .material-symbols-outlined {
    color: var(--md-primary);
    font-size: 22px;
}
.md-card-body { padding: 0 24px 24px; }
.md-card-body.flush { padding: 0; }

/* ---- Stat Cards ---- */
.md-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.md-stat-card {
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    padding: 20px;
    box-shadow: var(--md-elevation-1);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: box-shadow 0.2s, transform 0.2s;
}
.md-stat-card:hover {
    box-shadow: var(--md-elevation-2);
    transform: translateY(-1px);
}
.md-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--md-shape-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.md-stat-icon .material-symbols-outlined { font-size: 24px; }
.md-stat-icon.primary   { background: var(--md-primary-container); color: var(--md-primary); }
.md-stat-icon.warning   { background: var(--md-warning-container); color: var(--md-warning); }
.md-stat-icon.info      { background: var(--md-tertiary-container); color: var(--md-tertiary); }
.md-stat-icon.success   { background: var(--md-success-container); color: var(--md-success); }
.md-stat-icon.error     { background: var(--md-error-container); color: var(--md-error); }
.md-stat-info .md-stat-number {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: var(--md-on-surface);
}
.md-stat-info .md-stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    margin-top: 4px;
}

/* ---- Buttons ---- */
.md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--md-shape-full);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.4;
}
.md-btn .material-symbols-outlined { font-size: 18px; }

.md-btn-filled {
    background: var(--md-primary);
    color: var(--md-on-primary);
}
.md-btn-filled:hover {
    background: var(--md-primary-hover);
    box-shadow: var(--md-elevation-1);
}

.md-btn-tonal {
    background: var(--md-primary-container);
    color: var(--md-primary);
}
.md-btn-tonal:hover {
    box-shadow: var(--md-elevation-1);
    filter: brightness(0.96);
}

.md-btn-outlined {
    background: transparent;
    color: var(--md-primary);
    border: 1px solid var(--md-outline);
}
.md-btn-outlined:hover {
    background: var(--md-primary-container);
}

.md-btn-text {
    background: transparent;
    color: var(--md-primary);
    padding: 10px 16px;
}
.md-btn-text:hover { background: var(--md-primary-container); }

/* Button colors */
.md-btn-success { background: var(--md-success); color: white; }
.md-btn-success:hover { background: #166534; box-shadow: var(--md-elevation-1); }

.md-btn-error { background: var(--md-error); color: white; }
.md-btn-error:hover { background: #b91c1c; box-shadow: var(--md-elevation-1); }
.md-btn-error-outline { background: transparent; color: var(--md-error); border: 1px solid var(--md-error); }
.md-btn-error-outline:hover { background: var(--md-error-container); }

.md-btn-warning { background: var(--md-warning); color: white; }
.md-btn-warning:hover { background: #b45309; box-shadow: var(--md-elevation-1); }

.md-btn-gold { background: var(--md-secondary); color: white; }
.md-btn-gold:hover { background: #9e6900; box-shadow: var(--md-elevation-1); }

.md-btn-sm {
    padding: 6px 16px;
    font-size: 12px;
}
.md-btn-sm .material-symbols-outlined { font-size: 16px; }

.md-btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--md-shape-full);
    background: transparent;
    border: none;
    color: var(--md-on-surface-variant);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.md-btn-icon:hover { background: var(--md-surface-container); }

/* ---- Chips / Badges ---- */
.md-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: var(--md-shape-sm);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.md-chip-success { background: var(--md-success-container); color: #065f46; }
.md-chip-warning { background: var(--md-warning-container); color: #92400e; }
.md-chip-error   { background: var(--md-error-container);   color: #991b1b; }
.md-chip-primary { background: var(--md-primary-container); color: var(--md-primary); }
.md-chip-info    { background: var(--md-info-container);     color: #155e75; }
.md-chip-tertiary{ background: var(--md-tertiary-container); color: #4338ca; }
.md-chip-filled  { background: var(--md-primary); color: var(--md-on-primary); }
.md-chip-gold    { background: var(--md-secondary-container); color: #78350f; }

/* ---- Tables ---- */
.md-table-container {
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-1);
    overflow: hidden;
}
.md-table {
    width: 100%;
    border-collapse: collapse;
}
.md-table thead {
    background: var(--md-surface-container);
}
.md-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--md-outline-variant);
}
.md-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--md-outline-variant);
    color: var(--md-on-surface);
    vertical-align: middle;
}
.md-table tr:last-child td { border-bottom: none; }
.md-table tbody tr {
    transition: background 0.15s;
}
.md-table tbody tr:hover {
    background: var(--md-surface-container-low);
}

/* ---- Forms ---- */
.md-field {
    margin-bottom: 20px;
}
.md-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--md-on-surface);
    margin-bottom: 6px;
}
.md-field input,
.md-field textarea,
.md-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--md-outline);
    border-radius: var(--md-shape-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--md-on-surface);
    background: var(--md-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.md-field input:focus,
.md-field textarea:focus,
.md-field select:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(122,16,36,0.1);
}
.md-field textarea { min-height: 88px; resize: vertical; }
.md-field .md-error-msg {
    font-size: 12px;
    color: var(--md-error);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.md-field-hint {
    font-size: 12px;
    color: var(--md-on-surface-variant);
    margin-top: 4px;
}

/* ---- Alerts ---- */
.md-alert {
    padding: 14px 20px;
    border-radius: var(--md-shape-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.md-alert .material-symbols-outlined { font-size: 22px; flex-shrink: 0; }
.md-alert-success { background: var(--md-success-container); color: #065f46; }
.md-alert-error   { background: var(--md-error-container);   color: #991b1b; }
.md-alert-warning { background: var(--md-warning-container); color: #92400e; }
.md-alert-info    { background: var(--md-info-container);     color: #155e75; }

/* ---- Data Rows ---- */
.md-data-section {
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-1);
    overflow: hidden;
    margin-bottom: 20px;
}
.md-data-section-title {
    background: var(--md-primary);
    color: var(--md-on-primary);
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.md-data-section-title .material-symbols-outlined { font-size: 20px; }
.md-data-row {
    display: flex;
    padding: 12px 20px;
    border-bottom: 1px solid var(--md-outline-variant);
    align-items: flex-start;
    gap: 12px;
}
.md-data-row:last-child { border-bottom: none; }
.md-data-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 130px;
    padding-top: 2px;
    flex-shrink: 0;
}
.md-data-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-on-surface);
    flex: 1;
}

/* ---- Pagination ---- */
.md-pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
.md-pagination a, .md-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--md-shape-full);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}
.md-pagination a {
    color: var(--md-on-surface);
    background: transparent;
}
.md-pagination a:hover {
    background: var(--md-surface-container);
}
.md-pagination .current {
    background: var(--md-primary);
    color: var(--md-on-primary);
    font-weight: 600;
}
.md-pagination .disabled {
    color: var(--md-outline);
    pointer-events: none;
}

/* ---- Filters Bar ---- */
.md-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.md-filters input,
.md-filters select {
    padding: 10px 16px;
    border: 1.5px solid var(--md-outline);
    border-radius: var(--md-shape-full);
    font-size: 14px;
    font-family: inherit;
    background: var(--md-surface);
    color: var(--md-on-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.md-filters input:focus,
.md-filters select:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(122,16,36,0.1);
}
.md-filters input { min-width: 240px; }

/* ---- Pipeline ---- */
.md-pipeline {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-1);
    overflow: hidden;
}
.md-pipeline-stage {
    padding: 20px 16px;
    text-align: center;
    position: relative;
    transition: opacity 0.2s;
}
.md-pipeline-stage:not(:last-child) {
    border-right: 1px solid var(--md-outline-variant);
}
.md-pipeline-stage.locked { opacity: 0.35; }
.md-pipeline-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--md-shape-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
}
.md-pipeline-icon .material-symbols-outlined { font-size: 24px; }
.md-pipeline-count {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}
.md-pipeline-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    margin-top: 6px;
}
.md-pipeline-bar {
    margin-top: 12px;
    height: 4px;
    background: var(--md-surface-container);
    border-radius: 2px;
    overflow: hidden;
}
.md-pipeline-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* Pipeline colors */
.md-pipeline-stage.stage-1 .md-pipeline-icon { background: #fef3c7; color: #d97706; }
.md-pipeline-stage.stage-1 .md-pipeline-count { color: #d97706; }
.md-pipeline-stage.stage-1 .md-pipeline-bar-fill { background: #d97706; }

.md-pipeline-stage.stage-2 .md-pipeline-icon { background: #eef2ff; color: #6366f1; }
.md-pipeline-stage.stage-2 .md-pipeline-count { color: #6366f1; }
.md-pipeline-stage.stage-2 .md-pipeline-bar-fill { background: #6366f1; }

.md-pipeline-stage.stage-3 .md-pipeline-icon { background: #ecfeff; color: #0891b2; }
.md-pipeline-stage.stage-3 .md-pipeline-count { color: #0891b2; }
.md-pipeline-stage.stage-3 .md-pipeline-bar-fill { background: #0891b2; }

.md-pipeline-stage.stage-4 .md-pipeline-icon { background: #dcfce7; color: #15803d; }
.md-pipeline-stage.stage-4 .md-pipeline-count { color: #15803d; }
.md-pipeline-stage.stage-4 .md-pipeline-bar-fill { background: #15803d; }

/* ---- Stepper (detail view) ---- */
.md-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 20px;
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-1);
    margin-bottom: 24px;
    gap: 0;
}
.md-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
}
.md-step-circle {
    width: 44px;
    height: 44px;
    border-radius: var(--md-shape-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--md-on-surface-variant);
    background: var(--md-surface-container);
    transition: all 0.3s;
}
.md-step-circle .material-symbols-outlined { font-size: 20px; }
.md-step-label {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    text-align: center;
    line-height: 1.3;
}
.md-step-connector {
    flex: 1;
    height: 3px;
    background: var(--md-surface-container);
    margin: 22px 8px 0;
    min-width: 24px;
    border-radius: 2px;
}

.md-step.done .md-step-circle { background: var(--md-success); color: white; }
.md-step.done .md-step-label  { color: var(--md-success); font-weight: 600; }
.md-step-connector.done       { background: var(--md-success); }

.md-step.active .md-step-circle {
    background: var(--md-primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(122,16,36,0.15);
}
.md-step.active .md-step-label { color: var(--md-primary); font-weight: 600; }

.md-step.rejected .md-step-circle { background: var(--md-error); color: white; }
.md-step.rejected .md-step-label  { color: var(--md-error); font-weight: 600; }

/* ---- Action Panel ---- */
.md-action-panel {
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-1);
    padding: 24px;
    margin-bottom: 20px;
}
.md-action-panel h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.md-action-panel h3 .material-symbols-outlined {
    font-size: 22px;
    color: var(--md-primary);
}
.md-action-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.md-action-row .md-field { flex: 1; min-width: 120px; margin-bottom: 0; }

/* Dentro del sidebar, los campos siempre se apilan */
.show-actions-sticky .md-action-row {
    flex-direction: column;
    align-items: stretch;
}
.show-actions-sticky .md-action-row .md-field { min-width: unset; }

/* ---- Empty State ---- */
.md-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--md-on-surface-variant);
}
.md-empty .material-symbols-outlined {
    font-size: 56px;
    color: var(--md-outline);
    margin-bottom: 16px;
    display: block;
}
.md-empty h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--md-on-surface);
    margin-bottom: 8px;
}
.md-empty p {
    font-size: 14px;
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.md-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        linear-gradient(135deg, #3d0812 0%, #7a1024 50%, #4d0114 100%);
}
.md-login-card {
    background: var(--md-surface);
    border-radius: var(--md-shape-lg);
    padding: 40px 36px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--md-elevation-4);
}
.md-login-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--md-shape-md);
    background: var(--md-primary-container);
    color: var(--md-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}
.md-login-icon .material-symbols-outlined { font-size: 32px; }
.md-login-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--md-on-surface);
    text-align: center;
    margin-bottom: 4px;
}
.md-login-sub {
    font-size: 14px;
    color: var(--md-on-surface-variant);
    text-align: center;
    margin-bottom: 28px;
}
.md-login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 12px;
    color: var(--md-on-surface-variant);
}

/* ============================================================
   PUBLIC PAGES (keep backward compat)
   ============================================================ */
body.public-body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f5f0eb;
    background-image:
        linear-gradient(180deg, #4d0114 0%, #7a1024 180px, transparent 180px),
        linear-gradient(180deg, transparent 180px, #f5f0eb 180px);
    min-height: 100vh;
    color: var(--texto);
    padding: 20px;
}

.header {
    text-align: center;
    padding: 24px 20px 20px;
    color: white;
}
.header .logo-texto {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #d4a020;
    margin-bottom: 6px;
}
.header h1 { font-size: 24px; font-weight: 700; line-height: 1.3; margin-bottom: 4px; }
.header .subtitulo { font-size: 13px; opacity: 0.75; font-style: italic; }
.header .linea-decorativa {
    width: 40px; height: 3px;
    background: var(--md-secondary); margin: 12px auto 0; border-radius: 2px;
}

.card {
    background: white;
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-2);
    max-width: 560px;
    margin: 18px auto;
    overflow: hidden;
    border-top: 3px solid var(--md-secondary);
}
.card-header {
    background: var(--md-primary);
    color: white;
    padding: 18px 26px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.card-header .icono {
    font-size: 20px;
    background: rgba(255,255,255,0.12);
    width: 44px; height: 44px;
    border-radius: var(--md-shape-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: #d4a020;
}
.card-header h2 { font-size: 18px; font-weight: 600; margin-bottom: 2px; }
.card-header p  { font-size: 13px; opacity: 0.80; }
.card-body { padding: 28px 26px; }

/* Public form groups */
.form-grupo { margin-bottom: 20px; }
.form-grupo label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--md-on-surface);
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.form-grupo input,
.form-grupo textarea,
.form-grupo select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--md-outline);
    border-radius: var(--md-shape-sm);
    font-size: 16px;
    font-family: inherit;
    color: var(--md-on-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    background: white;
}
.form-grupo input:focus,
.form-grupo textarea:focus,
.form-grupo select:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(122,16,36,0.10);
}
.form-grupo input.error { border-color: var(--md-error); }
.form-grupo textarea { min-height: 88px; resize: vertical; font-size: 15px; }
.error-msg { font-size: 12px; color: var(--md-error); margin-top: 4px; }
.campo-ayuda { font-size: 13px; color: var(--md-on-surface-variant); margin-top: 5px; }

/* Legacy buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    border: none;
    border-radius: var(--md-shape-full);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-primario {
    background: var(--md-primary);
    color: white;
    width: 100%;
    justify-content: center;
    font-size: 15px;
    padding: 13px 24px;
}
.btn-primario:hover { background: var(--md-primary-hover); box-shadow: var(--md-elevation-2); }
.btn-secundario {
    background: white;
    color: var(--md-on-surface);
    border: 1px solid var(--md-outline);
}
.btn-secundario:hover { background: var(--md-surface-dim); }
.btn-verde { background: var(--md-success); color: white; }
.btn-verde:hover { background: #166534; }
.btn-dorado { background: var(--md-secondary); color: white; }
.btn-rojo { background: var(--md-error); color: white; }

/* Legacy badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--md-shape-sm);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-verde    { background: var(--md-success-container); color: #065f46; }
.badge-amarillo { background: var(--md-warning-container); color: #92400e; }
.badge-rojo     { background: var(--md-error-container);   color: #991b1b; }
.badge-primario { background: var(--md-primary); color: white; }

/* Legacy alerts */
.alerta {
    padding: 12px 16px;
    border-radius: var(--md-shape-sm);
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.55;
}
.alerta-error       { background: var(--md-error-container);   color: #991b1b; }
.alerta-exito       { background: var(--md-success-container); color: #065f46; }
.alerta-info        { background: var(--md-warning-container); color: #78350f; }
.alerta-advertencia { background: var(--md-warning-container); color: #713f12; }
.alerta-icono       { font-size: 15px; flex-shrink: 0; margin-top: 1px; }

/* Legacy datos */
.datos-participante {
    background: var(--md-surface);
    border-radius: var(--md-shape-md);
    box-shadow: var(--md-elevation-1);
    overflow: hidden;
    margin-bottom: 20px;
}
.datos-titulo {
    background: var(--md-primary);
    color: white;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.datos-fila {
    display: flex;
    padding: 12px 20px;
    border-bottom: 1px solid var(--md-outline-variant);
    align-items: flex-start;
    gap: 12px;
}
.datos-fila:last-child { border-bottom: none; }
.datos-etiqueta {
    font-size: 12px;
    font-weight: 600;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 130px;
    padding-top: 2px;
    flex-shrink: 0;
}
.datos-valor {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-on-surface);
}

/* Legacy exito grande */
.exito-grande { text-align: center; padding: 16px 10px; }
.exito-grande .icono-grande { font-size: 52px; color: var(--md-secondary); margin-bottom: 16px; display: block; }
.exito-grande h3 { font-size: 20px; color: var(--md-primary); margin-bottom: 10px; font-weight: 700; }
.exito-grande p { font-size: 14px; color: var(--md-on-surface-variant); line-height: 1.65; max-width: 400px; margin: 0 auto 20px; }

.footer { text-align: center; color: var(--md-on-surface-variant); font-size: 12px; padding: 18px; margin-top: 8px; }
.divider { height: 1px; background: var(--md-outline-variant); margin: 18px 0; }
.spinner { display: none; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.30); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dni-input-wrapper { position: relative; }
.dni-input-wrapper input { font-size: 26px; font-weight: 700; text-align: center; letter-spacing: 6px; padding: 16px 20px; font-family: 'Courier New', monospace; color: var(--md-primary); }
.contador-dni { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--md-on-surface-variant); font-weight: 700; pointer-events: none; }
.contador-dni.ok { color: var(--md-success); }
.contador-dni.error-len { color: var(--md-error); }

.upload-zone { background: var(--md-surface-container-low); border: 2px dashed var(--md-outline); border-radius: var(--md-shape-sm); padding: 36px; text-align: center; cursor: pointer; transition: all 0.15s; }
.upload-zone:hover, .upload-zone.drag { border-color: var(--md-primary); background: var(--md-primary-container); }
.upload-zone .icono { font-size: 40px; color: var(--md-secondary); margin-bottom: 10px; display: block; }
.upload-zone h3 { color: var(--md-primary); margin-bottom: 6px; font-size: 15px; }
.upload-zone p { color: var(--md-on-surface-variant); font-size: 13px; }

.btn-grupo { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn-grupo .btn { flex: 1; min-width: 140px; justify-content: center; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .md-sidebar { transform: translateX(-100%); }
    .md-sidebar.open { transform: translateX(0); box-shadow: var(--md-elevation-4); }
    .md-topbar { left: 0; }
    .md-topbar-menu { display: flex; }
    .md-main { margin-left: 0; }
    .md-pipeline { grid-template-columns: repeat(2, 1fr); }
    .md-stepper { flex-wrap: wrap; gap: 8px; padding: 16px; }
    .md-step-connector { display: none; }
    .md-step { min-width: 70px; }
}
@media (max-width: 900px) {
    /* Show detail: stack sidebar below data */
    .show-hero-identity { flex-wrap: wrap; }
    .show-hero-meta { font-size: 11px !important; flex-wrap: wrap; }
    .show-stepper-label { font-size: 10px; }
}

@media (max-width: 600px) {
    body { padding: 0; }
    .md-content { padding: 16px; }
    .md-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .md-stat-card { padding: 14px; gap: 10px; }
    .md-stat-icon { width: 40px; height: 40px; }
    .md-stat-icon .material-symbols-outlined { font-size: 20px; }
    .md-stat-info .md-stat-number { font-size: 22px; }
    .md-table-container { border-radius: 0; }
    .md-pipeline { grid-template-columns: 1fr 1fr; }
    .md-filters { flex-direction: column; }
    .md-filters input, .md-filters select { width: 100%; min-width: unset; }
    .md-action-row { flex-direction: column; }
    .md-data-label { min-width: 100px; font-size: 11px; }

    /* Public */
    .header h1 { font-size: 20px; }
    .card-body { padding: 20px 16px; }
    .card-header { padding: 14px 16px; }
    .btn-grupo { flex-direction: column; }
    .btn-grupo .btn { min-width: unset; }
}

/* Scrollbar styling */
.md-sidebar::-webkit-scrollbar { width: 4px; }
.md-sidebar::-webkit-scrollbar-track { background: transparent; }
.md-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* Utility: responsive table wrapper */
.md-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Detail grid — responsive CRM layout */
.md-detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}
@media (min-width: 1400px) {
    .md-detail-grid {
        grid-template-columns: 1fr 400px;
        gap: 28px;
    }
}
@media (max-width: 1100px) {
    .md-detail-grid {
        grid-template-columns: 1fr 300px;
        gap: 16px;
    }
}
@media (max-width: 900px) {
    .md-detail-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Pagination — MD3-style, used by vendor/pagination/md.blade.php
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.md-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 4px;
}
.md-pagination-info {
    font-size: 13px;
    color: var(--md-on-surface-variant);
}
.md-pagination-info strong {
    color: var(--md-on-surface);
    font-weight: 600;
}
.md-pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.md-pagination-pages {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 4px;
}
.md-pagination-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.md-pagination-page:hover {
    background: var(--md-surface-container-high);
    color: var(--md-on-surface);
}
.md-pagination-page.active {
    background: var(--md-primary);
    color: var(--md-on-primary);
    font-weight: 600;
}
.md-pagination-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 36px;
    color: var(--md-on-surface-variant);
    font-size: 13px;
}
@media (max-width: 700px) {
    .md-pagination {
        flex-direction: column;
        align-items: stretch;
    }
    .md-pagination-controls {
        justify-content: center;
    }
    .md-pagination-info {
        text-align: center;
    }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Preview modal — used by _preview-modal.blade.php
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.md-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.md-preview-modal[hidden] { display: none; }
.md-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: zoom-out;
}
.md-preview-dialog {
    position: relative;
    background: var(--md-surface);
    border-radius: var(--md-shape-lg);
    box-shadow: var(--md-elevation-4);
    max-width: min(960px, 100%);
    max-height: min(90vh, 100%);
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: previewIn 0.18s ease-out;
}
@keyframes previewIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}
.md-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--md-outline-variant);
    background: var(--md-surface-container-low);
    gap: 12px;
}
.md-preview-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.md-preview-title-wrap h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--md-on-surface);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.md-preview-title-wrap .material-symbols-outlined {
    color: var(--md-primary);
    font-size: 22px;
    flex-shrink: 0;
}
.md-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.md-preview-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--md-on-surface-variant);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.md-preview-close:hover {
    background: var(--md-surface-container-high);
}
.md-preview-body {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: var(--md-surface-container-lowest, #fafafa);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}
.md-preview-body img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--md-shape-sm);
    box-shadow: var(--md-elevation-1);
}
.md-preview-body iframe {
    width: 100%;
    height: 75vh;
    border: 0;
    border-radius: var(--md-shape-sm);
    background: white;
}
.md-preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--md-error);
    font-size: 14px;
    padding: 32px;
    text-align: center;
}
.md-preview-error .material-symbols-outlined { font-size: 48px; }

/* Fix: el atributo `hidden` debe ganar sobre `display: flex` (especificidad) */
.md-preview-error[hidden],
.md-preview-body img[hidden],
.md-preview-body iframe[hidden] {
    display: none;
}

@media (max-width: 700px) {
    .md-preview-modal { padding: 12px; }
    .md-preview-dialog { max-height: 95vh; }
    .md-preview-body iframe { height: 60vh; }
}
