:root {
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --bg-app: #F4F6F9; /* Soft Light Gray Content Background for shadow contrast */
    --surface: #FFFFFF; /* Pure White Card Surface */
    --primary: #003B5C; /* Deep Corporate Navy */
    --primary-hover: #005F8D; /* Ocean Blue */
    --secondary: #005F8D;
    --border-color: transparent; /* No visible border for containers */
    --text-main: #1D1F21; /* Charcoal Dark Slate */
    --text-muted: #6B7280; /* Muted Slate */
    
    /* New Palette Accents */
    --neon: #E1F5FE; /* Soft Cyan Ice active state */
    --neon-hover: #B3E5FC;
    --sidebar-bg: #FFFFFF; /* White sidebar background */
    --sidebar-color: #1D1F21;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.05), 0 2px 6px rgba(0, 0, 0, 0.02);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 50px;
}

/* Global Reset & Sizing Adjustments (Compact Mode) */
html, body {
    font-family: var(--font-main);
    background-color: var(--bg-app);
    color: var(--text-main);
    letter-spacing: -0.015em;
    -webkit-font-smoothing: antialiased;
    font-size: 0.825rem; /* Compact size globally (approx 13px) */
    line-height: 1.4;
    overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d4d4d8;
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: #a1a1aa;
}

/* Compact Typography */
h1, .h1 { font-size: 1.4rem !important; font-weight: 700; margin-bottom: 0.25rem; }
h2, .h2 { font-size: 1.2rem !important; font-weight: 600; margin-bottom: 0.25rem; }
h3, .h3 { font-size: 1.05rem !important; font-weight: 600; }
h4, .h4 { font-size: 0.95rem !important; font-weight: 600; }
p, .lead { font-size: 0.8rem; color: var(--text-muted); }

/* Layout Structure */
#wrapper {
    display: flex;
    background-color: var(--bg-app);
    padding: 12px;
    gap: 12px;
    height: 100vh;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Sidebar: Narrow, Pill-shaped Capsule (New light sidebar theme) */
#sidebar-wrapper {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-color);
    border-radius: 100px; /* Perfect pill capsule */
    width: 60px; /* Slim and elegant */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 22px 0 16px 0;
    box-shadow: var(--shadow-lg);
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--border-color);
}

#sidebar-wrapper .sidebar-heading {
    margin-bottom: 20px;
    border: none;
    padding: 0;
}

/* Navigation Links - Centered Circular Buttons matching new theme */
#sidebar-wrapper .nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%; /* Perfect circle */
    color: var(--text-muted); /* Muted inactive state */
    margin: 3px auto;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-decoration: none;
    position: relative;
}

#sidebar-wrapper .nav-link:hover {
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.04);
}

#sidebar-wrapper .nav-link.active {
    color: var(--text-main) !important;
    background-color: rgba(0, 0, 0, 0.06) !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

/* Micro-animation when clicked (feedback) */
#sidebar-wrapper .nav-link:active {
    transform: scale(0.90);
}

#sidebar-wrapper .nav-link.text-danger-hover:hover {
    color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.08) !important;
}

/* Floating Logo Toggle Button - Gorgeous Dark Gradient + Neon color */
#sidebar-logo-container {
    position: absolute;
    top: 24px;
    left: 23px;
    width: 38px;
    height: 38px;
    z-index: 1050;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: linear-gradient(135deg, #1C1E21 0%, #343A40 100%) !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(212, 249, 83, 0.25);
    border: 1px solid rgba(212, 249, 83, 0.2);
}

#sidebar-logo-container:hover {
    transform: scale(1.08) rotate(-5deg);
    box-shadow: 0 6px 18px rgba(212, 249, 83, 0.4);
}

#sidebar-logo-container:active {
    transform: scale(0.95);
}

#sidebar-logo-container div {
    background: transparent !important;
    color: var(--neon) !important;
    font-weight: 800 !important;
    font-size: 1.15rem !important;
}

/* Profile / Avatar at bottom of sidebar */
#sidebar-wrapper .rounded-circle {
    border: 2px solid white !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 99%, #FECFEF 100%) !important;
    color: #FFFFFF !important;
}

#sidebar-wrapper .rounded-circle:hover {
    transform: scale(1.08);
    border-color: var(--neon) !important;
    box-shadow: 0 4px 12px rgba(212, 249, 83, 0.3);
}

/* Hide navigation label text to keep it ultra-minimalist */
#sidebar-wrapper .nav-link-text {
    display: none;
}

/* Sidebar Collapse (Smooth Hiding without page shifts) */
#wrapper.collapsed #sidebar-wrapper {
    width: 0;
    padding: 22px 0 16px 0;
    margin-right: -12px; /* Offset the flex gap */
    opacity: 0;
    pointer-events: none;
    border-color: transparent;
}

/* Page content section */
#page-content-wrapper {
    flex: 1;
    background-color: var(--surface);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    min-width: 0;
}

/* Header / Navbar Customization - Compact height */
.custom-header {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface);
}

/* Compact Margins & Paddings globally */
.container-fluid {
    padding: 16px 20px !important;
}

/* Cards Sizing */
.card, .premium-panel, .premium-card {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    margin-bottom: 12px;
}

.card:hover, .premium-panel:hover, .premium-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 45px -10px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.01);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
}

.card-body {
    padding: 14px 16px;
}

/* Compact Forms overrides matching the clean light theme */
.form-control, .form-select {
    font-size: 0.82rem;
    padding: 7px 12px;
    border: 1px solid #CBD5E1;
    border-radius: var(--radius-md);
    background-color: #ffffff;
    color: #0F172A !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.01);
    transition: all 0.2s ease;
    height: auto;
}

.form-control::placeholder, input::placeholder, textarea::placeholder {
    color: #64748B !important;
    opacity: 1 !important;
    font-weight: 400;
}

.form-control:focus, .form-select:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background-color: #ffffff;
    color: #0F172A !important;
    outline: none;
}

.form-label {
    font-weight: 600;
    font-size: 0.775rem;
    color: #334155;
    margin-bottom: 3px;
}

/* Compact Pill Buttons with high contrast */
.btn {
    font-size: 0.775rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: #2563EB !important;
    border-color: #2563EB !important;
    color: #FFFFFF !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: #1D4ED8 !important;
    border-color: #1D4ED8 !important;
    color: #FFFFFF !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.btn-secondary, .btn-light {
    background-color: #ffffff;
    border: 1px solid #CBD5E1;
    color: #334155;
}

.btn-secondary:hover, .btn-light:hover {
    background-color: #F1F5F9 !important;
    border-color: #94A3B8 !important;
    color: #0F172A !important;
    transform: translateY(-1px);
}

.btn-outline-primary {
    border: 1px solid #2563EB !important;
    color: #2563EB !important;
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: #2563EB !important;
    border-color: #2563EB !important;
    color: #FFFFFF !important;
}

.btn-outline-secondary {
    border: 1px solid #CBD5E1 !important;
    color: #334155 !important;
    background-color: transparent;
}

.btn-outline-secondary:hover {
    background-color: #334155 !important;
    border-color: #334155 !important;
    color: #FFFFFF !important;
}

.btn-outline-danger {
    border: 1px solid #EF4444 !important;
    color: #DC2626 !important;
    background-color: transparent;
}

.btn-outline-danger:hover {
    background-color: #DC2626 !important;
    border-color: #DC2626 !important;
    color: #FFFFFF !important;
}

.btn-outline-warning {
    border: 1px solid #F59E0B !important;
    color: #B45309 !important;
    background-color: transparent;
}

.btn-outline-warning:hover {
    background-color: #D97706 !important;
    border-color: #D97706 !important;
    color: #FFFFFF !important;
}

.btn-outline-success {
    border: 1px solid #10B981 !important;
    color: #059669 !important;
    background-color: transparent;
}

.btn-outline-success:hover {
    background-color: #059669 !important;
    border-color: #059669 !important;
    color: #FFFFFF !important;
}

/* Badges */
.badge {
    padding: 4px 8px;
    font-weight: 600;
    font-size: 0.7rem;
    border-radius: var(--radius-pill);
}

/* Tables Styling - Ultra compact */
.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
}

.table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    vertical-align: middle;
}

/* Layout spacing tuning for small screens */
.row {
    --bs-gutter-x: 12px;
    --bs-gutter-y: 12px;
}

.g-4, .gy-4, .gx-4 {
    --bs-gutter-x: 12px !important;
    --bs-gutter-y: 12px !important;
}

.mb-4 {
    margin-bottom: 12px !important;
}
.mt-4 {
    margin-top: 12px !important;
}
.py-3 {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
}
.py-4 {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

/* Sidebar Nav Links tweaks: Hidden by default (contracted), shown when expanded */
.custom-sidebar .nav-link-text {
    display: none;
}
.custom-sidebar.expanded .nav-link-text {
    display: inline-block !important;
}

.custom-sidebar .menu-item {
    text-decoration: none;
}

.custom-sidebar .menu-item svg {
    width: 20px;
    height: 20px;
    transition: var(--transition-smooth);
}

/* Ensure stroke-based SVGs don't get filled in with black/gray color */
.custom-sidebar .menu-item svg[fill="none"] {
    fill: none !important;
    stroke: currentColor !important;
}

.top-navigation {
    padding-top: 15px !important;
}

/* Universal Borderless & Soft Drop-Shadow for ALL Containers (More rounded: 20px) */
.card,
.panel,
.modal-content,
.data-card,
.queue-item,
.doc-viewer,
.alert-panel,
.premium-card,
.premium-panel,
.activation-card,
.report-card,
.zd-container,
.zd-card,
.kanban-card,
.kanban-column,
.stat-card,
.content-card,
.info-box,
.table-responsive,
.filter-card,
.form-card,
.search-card,
.detail-card,
[class*="-card"],
[class*="-panel"] {
    border: none !important;
    border-radius: 20px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.02) !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Remove hard outline borders from Bootstrap rounded utility boxes */
.border, .border-top, .border-bottom, .border-start, .border-end {
    border-color: rgba(0, 0, 0, 0.02) !important;
}

/* Floating Pill Search Input */
.search-pill-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-pill-input {
    width: 100%;
    padding: 11px 50px 11px 22px;
    border-radius: 50px !important;
    border: none !important;
    background-color: #FFFFFF !important;
    color: var(--text-main) !important;
    font-size: 0.875rem;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05), 0 1px 4px rgba(0, 0, 0, 0.02) !important;
    outline: none !important;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-pill-input:focus {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.09) !important;
}

/* Standalone Borderless Search Icon Button */
.search-icon-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3D3D3D;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease, background-color 0.2s ease;
}

.search-icon-btn:hover {
    color: #000000;
    background-color: rgba(0, 0, 0, 0.05) !important;
    transform: translateY(-50%) scale(1.12);
}

.search-icon-btn:active {
    transform: translateY(-50%) scale(0.88) rotate(-15deg);
}

/* Spinner Animation for Loading State */
@keyframes spin-loader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spin-icon {
    animation: spin-loader 0.8s linear infinite;
    color: #10b981 !important;
}

/* Free-floating Filter Select Pills */
.filter-pill-select {
    border-radius: 50px !important;
    border: none !important;
    background-color: #FFFFFF !important;
    padding: 10px 20px !important;
    font-size: 0.85rem !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05), 0 1px 4px rgba(0, 0, 0, 0.02) !important;
    color: var(--text-main) !important;
    outline: none !important;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.filter-pill-select:focus {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.09) !important;
}

/* ============================================================ */
/* ACCESSIBILITY PALETTES (DALTONISMO & ALTO CONTRASTE)       */
/* ============================================================ */

/* 1. Protanopía / Deuteranopía (Adaptación Rojo-Verde) */
body.theme-protanopia {
    --bg-main: #F8FAFC;
    --text-main: #0F172A;
    --accent-blue: #1D4ED8;
    --accent-gold: #D97706;
}

body.theme-protanopia .badge-status,
body.theme-protanopia .badge-success,
body.theme-protanopia .text-success {
    color: #1D4ED8 !important;
    background-color: rgba(29, 78, 216, 0.12) !important;
}

body.theme-protanopia .badge-danger,
body.theme-protanopia .text-danger {
    color: #D97706 !important;
    background-color: rgba(217, 119, 6, 0.12) !important;
}

/* 2. Tritanopía (Adaptación Azul-Amarillo) */
body.theme-tritanopia {
    --bg-main: #F1F5F9;
    --text-main: #1E293B;
    --accent-red: #DC2626;
    --accent-teal: #0D9488;
}

body.theme-tritanopia .badge-status,
body.theme-tritanopia .badge-primary,
body.theme-tritanopia .text-primary {
    color: #DC2626 !important;
    background-color: rgba(220, 38, 38, 0.12) !important;
}

body.theme-tritanopia .badge-info,
body.theme-tritanopia .text-info {
    color: #0D9488 !important;
    background-color: rgba(13, 148, 136, 0.12) !important;
}

/* 3. Alto Contraste Neutro / Heterocromía (Anti-Fatiga Visual) */
body.theme-high-contrast {
    background-color: #0F172A !important;
    color: #F8FAFC !important;
}

body.theme-high-contrast .custom-sidebar,
body.theme-high-contrast .card,
body.theme-high-contrast .panel,
body.theme-high-contrast .mod-card,
body.theme-high-contrast .stat-card,
body.theme-high-contrast .modal-content {
    background-color: #1E293B !important;
    color: #F8FAFC !important;
    border: 1px solid #334155 !important;
}

body.theme-high-contrast .text-muted {
    color: #94A3B8 !important;
}

body.theme-high-contrast a,
body.theme-high-contrast .nav-link {
    color: #38BDF8 !important;
}