:root {
    --bg: #02040a;
    --panel: rgba(13, 17, 28, 0.8);
    --primary: #3b82f6;
    --secondary: #06b6d4;
    /* Default Secondary Color */
    --border: rgba(255, 255, 255, 0.07);
    --success: #4ade80;
    --danger: #ef4444;
    --text-muted: #94a3b8;
}

.light-mode {
    --bg: #f8fafc;
    --panel: rgba(255, 255, 255, 0.9);
    --border: rgba(0, 0, 0, 0.1);
    --text-muted: #64748b;
    --success: #15803d;
    /* Darker green for white bg */
    --danger: #b91c1c;
    /* Darker red for white bg */
}

.light-mode body {
    color: #1e293b;
    background: #f1f5f9;
}

/* Light Mode Input Fixes */
.light-mode .inp-field,
.light-mode input:not([type="checkbox"]):not([type="radio"]),
.light-mode select {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    /* Dark text for inputs */
}

/* Light Mode Text Fixes */
.light-mode .feature-title,
.light-mode .logo-text,
.light-mode h1,
.light-mode h2,
.light-mode h3,
.light-mode strong,
.light-mode label {
    color: #0f172a !important;
}

.light-mode .menu-link {
    color: #475569;
}

.light-mode .menu-link:hover:not(.active) {
    color: #0f172a;
    background: rgba(0, 0, 0, 0.05);
}

.light-mode .vitalicia-container {
    color: #475569 !important;
}

/* Light Mode Fixes */
.light-mode .sidebar {
    background: #ffffff !important;
}

.light-mode .glass,
.light-mode .glass-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
}

/* Fix Card Text in Light Mode */
.light-mode .glass div,
.light-mode .glass span,
.light-mode .glass-card div,
.light-mode .glass-card span {
    color: #334155 !important;
    /* Dark grey for general text */
}

/* Fix Specific Card Titles/Numbers Override */
.light-mode .glass div[style*="font-size: 32px"],
.light-mode .glass div[style*="font-size: 20px"] {
    color: #0f172a !important;
    /* Almost black for big numbers */
}

/* Fix Table Text */
.light-mode table td {
    color: #334155;
}

.light-mode table strong {
    color: #0f172a;
}

.light-mode table td[data-label="Key"] div {
    color: #334155 !important;
}

/* Button Text Exception: Always White */
.light-mode .btn-neon,
.light-mode .btn-crear {
    color: white !important;
}

/* Light Mode Checkbox Fix */
.light-mode input[type="checkbox"] {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.light-mode input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

/* Light Mode Modal Fix */
.light-mode .modal-content {
    background: #ffffff !important;
    border-color: #e2e8f0;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.light-mode .modal-content label {
    color: #475569 !important;
}

.light-mode .modal-content h3 {
    color: #0f172a !important;
}

.light-mode .tech-btn {
    background: white;
    border-color: #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.light-mode .tech-btn:hover {
    background: #f8fafc;
    border-color: var(--primary);
}

body {
    background-color: var(--bg);
    color: #f1f5f9;
    font-family: 'Outfit', sans-serif;
    margin: 0;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.glass {
    background: var(--panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
}

.btn-neon {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: 0.3s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn-neon:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
}

/* Feature Grid */
/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Force 3 columns on PC */
    gap: 30px;
    max-width: 1000px;
    margin: 50px auto;
    padding: 0 20px;
}

@media (max-width: 900px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 cols on tablet */
    }
}

@media (max-width: 600px) {
    .feature-grid {
        grid-template-columns: 1fr;
        /* 1 col on mobile */
    }
}

.feature-card {
    text-align: center;
    padding: 20px;
}

.logo-text {
    color: white;
    /* Default Dark Mode */
}

.feature-icon-box {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px auto;
    font-size: 24px;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.feature-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
    color: white;
}

.feature-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Status Pill */
.status-pill {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.2);
    color: var(--success);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 0;
}

/* Layout */
.home-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #0a1020 0%, #02040a 100%);
    padding: 40px 20px;
    box-sizing: border-box;
    transition: background 0.3s;
}

.light-mode .home-container {
    background: radial-gradient(circle at center, #ffffff 0%, #f1f5f9 100%);
}

.dash-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    position: fixed;
    height: 100vh;
    padding: 40px 25px;
    border-right: 1px solid var(--border);
    background: #030610;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: 0.3s;
}

.main-content {
    margin-left: 280px;
    padding: 60px;
    width: calc(100% - 280px);
    box-sizing: border-box;
    min-height: 100vh;
}

/* Nav */
.menu-link {
    padding: 16px 20px;
    margin-bottom: 10px;
    color: #64748b;
    text-decoration: none;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
    transition: 0.3s;
}

.menu-link.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.menu-link:hover:not(.active) {
    color: #fff;
    background: rgba(255, 255, 255, 0.02);
}

.menu-toggle {
    display: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    padding: 5px;
}

/* UI Elements */
.inp-field,
input:not([type="checkbox"]):not([type="radio"]),
input[type="text"],
input[type="date"],
input[type="password"],
select {
    width: 100%;
    height: 54px;
    /* Explicit height */
    padding: 0 16px;
    background: #0d111c !important;
    /* Force dark background */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #cbd5e1 !important;
    /* Softer text color */
    border-radius: 12px;
    margin-bottom: 18px;
    outline: none;
    box-sizing: border-box;
    transition: 0.3s;
    font-size: 14px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    /* Remove default browser styling */
    display: flex;
    align-items: center;
}

/* Custom Checkbox */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: 0.3s;
    margin-right: 10px;
}

input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

input[type="checkbox"]:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.inp-field:focus,
input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.tech-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    padding: 18px;
    border-radius: 16px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
    transition: 0.3s;
    text-align: left;
    text-decoration: none;
    box-sizing: border-box;
}

.tech-btn:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
}

.alert {
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    font-size: 14px;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    box-sizing: border-box;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #f87171;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.1);
    backdrop-filter: blur(5px);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 15px;
    font-size: 11px;
    color: #475569;
    letter-spacing: 1px;
    text-transform: uppercase;
}

td {
    padding: 15px;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        box-shadow: 0 0 0px var(--success);
    }

    50% {
        opacity: 1;
        box-shadow: 0 0 15px var(--success);
    }

    100% {
        opacity: 0.5;
        box-shadow: 0 0 0px var(--success);
    }
}

/* Styles from Admin Panel (Merged) */
.glass-card {
    background: var(--panel);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 15px;
    align-items: end;
}

.btn-crear {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    height: 54px;
    /* Exact match to input height */
    padding: 0 20px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 1px;
    margin-bottom: 18px;
    /* Match input margin for grid alignment */
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-refresh {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.vitalicia-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0;
    /* Removed top margin to move it up */
    font-size: 14px;
    color: #e2e8f0;
    /* Brighter text (slate-200) */
    cursor: pointer;
    font-weight: 500;
    width: fit-content;
}

.vitalicia-container input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.exp-badge {
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 800;
    display: inline-block;
    white-space: nowrap;
}

/* Modals */
/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: #0b1222;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--border);
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
    /* Custom Scrollbar for modal */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.modal-content h3 {
    margin-top: 0;
    font-weight: 900;
}

.modal-content label {
    display: block;
    font-size: 10px;
    color: #475569;
    margin-bottom: 5px;
    font-weight: 800;
}

/* Default Mobile Header (Hidden on Laptop/PC) */
.mobile-header {
    display: none;
}

/* Button Override for tables inside glass card */
/* Button Override for tables inside glass card */
.action-btn,
.delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    width: 32px;
    /* Fixed width for symmetry */
    height: 32px;
    /* Fixed height for symmetry */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    /* Optional hover effect shape */
    transition: 0.2s;
    text-decoration: none;
}

.action-btn:hover,
.delete-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.action-btn {
    color: var(--primary);
}

.delete-btn {
    color: #ef4444;
}

/* Responsive Mobile Dropdown */
@media (max-width: 768px) {

    /* 1. Off-Canvas Sidebar */
    .sidebar {
        width: 280px;
        height: 100vh;
        /* Helper for mobile browsers to handle bottom bar */
        height: 100dvh;
        position: fixed;
        left: -290px;
        top: 0;
        z-index: 2000;
        padding: 40px 25px 80px 25px;
        /* Extra bottom padding for Safari */
        border-right: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        background: #030610;
        overflow-y: auto;
        /* Allow scroll if menu is long */
    }

    .sidebar.active {
        left: 0;
    }

    /* Force Nav display */
    nav#main-nav {
        display: flex !important;
        flex-direction: column;
        position: static;
        width: 100%;
        background: transparent;
        border: none;
        padding: 0;
        margin-top: 20px;
        margin-bottom: 20px;
    }

    /* Ensure links differ from background */
    .menu-link {
        color: #94a3b8;
        display: flex;
    }

    .logo-text {
        font-size: 24px !important;
        margin-bottom: 20px !important;
        display: block !important;
    }

    .logout-btn {
        display: flex;
        margin-top: auto;
        /* Push to bottom */
        margin-bottom: 20px;
    }

    .menu-link.logout-btn-mobile {
        display: none !important;
    }

    /* Modal Mobile Fix */
    .modal-content {
        width: 90%;
        margin: 0;
        /* Centered by absolute position */
        max-height: 80dvh;
        /* Safe height for mobile */
        overflow-y: auto;
        /* Force scroll */
        -webkit-overflow-scrolling: touch;
        /* Smooth scroll iOS */
        overscroll-behavior: contain;
        /* Prevent body scroll logic */
        touch-action: pan-y;
        /* Optimize touch */
        padding: 20px;
        /* Reduce padding */
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        position: absolute;
    }

    .modal-content h3 {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .modal-content label {
        margin-bottom: 3px;
    }

    /* Ensure scrollbar doesn't hide content */
    .modal-content::-webkit-scrollbar {
        width: 4px;
    }

    /* 2. Main Content & Header */
    .main-content {
        margin-left: 0;
        padding: 80px 20px 30px 20px;
        width: 100%;
    }

    /* Mobile Header */
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: var(--panel);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border);
        z-index: 1001;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px;
        box-sizing: border-box;
    }

    .menu-toggle {
        display: block;
        font-size: 22px;
        color: white;
        /* Ensure visible */
        cursor: pointer;
    }

    /* 3. Tables */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        display: block;
        margin-bottom: 20px;
        border: 1px solid var(--border);
        /* Ensure border is visible */
    }

    table {
        width: 100%;
        min-width: 600px;
        /* Force horizontal scroll on small screens */
        border-collapse: collapse;
    }

    /* Reset Display for Table Elements */
    .table-wrapper table {
        display: table;
    }

    .table-wrapper thead {
        display: table-header-group;
    }

    .table-wrapper tbody {
        display: table-row-group;
    }

    .table-wrapper tr {
        display: table-row;
        background: transparent;
        border: none;
    }

    .table-wrapper th,
    .table-wrapper td {
        display: table-cell;
        text-align: left;
        padding: 15px;
        vertical-align: middle;
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
        /* Prevent wrapping */
    }

    /* Fix alignment by forcing consistent padding/borders */
    .table-wrapper th {
        background: rgba(255, 255, 255, 0.02);
        color: #94a3b8;
        font-weight: 800;
        text-transform: uppercase;
        font-size: 11px;
    }

    .table-wrapper td::before {
        content: none;
    }

    /* Home Page Mobile Tweaks */
    .home-container h1 {
        font-size: 40px !important;
    }

    .home-container p {
        font-size: 15px !important;
        padding: 0 10px;
    }

    .btn-neon {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
        max-width: 100%;
        margin: 0;
    }

    .feature-grid {
        margin-top: 30px !important;
        gap: 20px !important;
    }

    /* 4. General Grids */
    div[style*="grid-template-columns"],
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        margin: 15% auto;
        padding: 20px;
    }

    h1 {
        font-size: 24px !important;
    }

    /* Overlay for Sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
        /* Darker */
        z-index: 1500;
        opacity: 0;
        visibility: hidden;
        transition: 0.3s;
        backdrop-filter: blur(5px);
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* Theme Swatches */
.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.theme-swatch:hover {
    transform: scale(1.05);
}

.swatch-colors {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.swatch-colors span {
    width: 24px;
    height: 24px;
}

.swatch-name {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Force Status Colors in Light Mode */
.light-mode div[style*="var(--success)"] {
    color: #4ade80 !important;
}

.light-mode div[style*="var(--danger)"] {
    color: #ef4444 !important;
}