* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.subtitle {
    opacity: 0.9;
    font-size: 14px;
}

.tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
}

.tab-btn.active {
    background: white;
    color: #0066cc;
    border-bottom: 3px solid #0066cc;
}

main {
    padding: 30px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border-left: 4px solid #6c757d;
}

.stat-card.valid {
    border-left-color: #28a745;
}

.stat-card.expiring {
    border-left-color: #ffc107;
}

.stat-card.expired {
    border-left-color: #dc3545;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #333;
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.upcoming-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #333;
}

.search-bar {
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

.certificate-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.certificate-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #6c757d;
    transition: transform 0.2s;
}

.certificate-card:hover {
    transform: translateX(5px);
}

.certificate-card.valid {
    border-left-color: #28a745;
}

.certificate-card.expiring {
    border-left-color: #ffc107;
}

.certificate-card.expired {
    border-left-color: #dc3545;
}

.cert-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.cert-name {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.cert-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.cert-status.valid {
    background: #d4edda;
    color: #155724;
}

.cert-status.expiring {
    background: #fff3cd;
    color: #856404;
}

.cert-status.expired {
    background: #f8d7da;
    color: #721c24;
}

.cert-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.cert-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn-edit, .btn-delete {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.btn-edit {
    background: #0066cc;
    color: white;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #0066cc;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
}

.btn-secondary {
    width: 100%;
    padding: 15px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 1000;
}

.notification.show {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/*@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 22px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cert-details {
        grid-template-columns: 1fr;
    }


/* Modal */
/* ... [keep all your existing CSS above] ... */

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
}
*/

/* ✅ Icon Button (OUTSIDE media query) */
.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ✅ Modal (OUTSIDE media query) */
.modal {
    display: none; 
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex; 
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: #fff;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    font-size: 22px;
    color: #333;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

.settings-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 8px;
}

.settings-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    line-height: 1.5;
}

.danger-zone {
    background: #fff5f5;
    border: 2px solid #ffcccc;
    border-radius: 12px;
    padding: 20px;
}

.danger-zone h3 {
    color: #dc3545;
}

.btn-danger {
    width: 100%;
    padding: 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:hover {
    background: #c82333;
}

.import-preview {
    margin-top: 15px;
    padding: 20px;
    background: #f0f8ff;
    border: 2px solid #0066cc;
    border-radius: 8px;
}

.import-preview p {
    margin-bottom: 15px;
    color: #333;
}

.import-options input[type="radio"] {
    margin-right: 10px;
}

.import-options label {
    display: block;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.import-options label:hover {
    border-color: #0066cc;
    background: #f0f8ff;
}

.import-options input[type="radio"] {
    margin-right: 10px;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 22px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cert-details {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
}

/* =========================================
   DARK MODE STYLES
   ========================================= */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
body.dark-mode .container {
    background: #1e1e2f;
    color: #e0e0e0;
}
body.dark-mode header {
    background: linear-gradient(135deg, #0f3460 0%, #000000 100%);
}
body.dark-mode .tabs {
    background: #2a2a40;
    border-bottom-color: #444;
}
body.dark-mode .tab-btn {
    color: #aaa;
}
body.dark-mode .tab-btn.active {
    background: #1e1e2f;
    color: #4da6ff;
    border-bottom-color: #4da6ff;
}
body.dark-mode .stat-card,
body.dark-mode .certificate-card,
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea,
body.dark-mode .search-bar input {
    background: #2a2a40;
    color: #e0e0e0;
    border-color: #444;
}
body.dark-mode .stat-number,
body.dark-mode .cert-name,
body.dark-mode .settings-section h3,
body.dark-mode .modal-header h2,
body.dark-mode .form-group label {
    color: #ffffff;
}
body.dark-mode .stat-label,
body.dark-mode .cert-details,
body.dark-mode .settings-description {
    color: #aaaaaa;
}
body.dark-mode .modal-content {
    background: #1e1e2f;
}
body.dark-mode .modal-header {
    background: #2a2a40;
    border-bottom-color: #444;
}
body.dark-mode .import-options label {
    background: #2a2a40;
    border-color: #444;
    color: #e0e0e0;
}
body.dark-mode .danger-zone {
    background: #2a1a1a;
    border-color: #552222;
}
body.dark-mode .empty-state {
    color: #888;
}

/* =========================================
   CERTIFICATE IMAGE & NOTES STYLES
   ========================================= */
.cert-image {
    max-width: 100%;
    max-height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid #ddd;
}
body.dark-mode .cert-image {
    border-color: #444;
}
.cert-notes {
    margin-top: 10px;
    color: #666;
    font-size: 14px;
}
body.dark-mode .cert-notes {
    color: #aaaaaa;
}

/* =========================================
   IMAGE LIGHTBOX STYLES
   ========================================= */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000; /* Sits above the settings modal */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}
.lightbox.active {
    display: flex;
}
.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
}

/* =========================================
   PRINT / PDF EXPORT STYLES
   ========================================= */
@media print {
    /* Hide everything we don't want in the PDF */
    header, .tabs, .search-bar, .cert-actions, .notification, 
    #settings-modal, .lightbox, #dashboard, #add, #theme-toggle-btn, #settings-btn {
        display: none !important;
    }
    
    /* Reset backgrounds for printing */
    body {
        background: white !important;
        padding: 0 !important;
    }
    .container {
        box-shadow: none !important;
        max-width: 100% !important;
        background: white !important;
        border-radius: 0 !important;
    }
    
    /* Ensure the certificates list is visible */
    #certificates {
        display: block !important;
    }
    
    /* Style the certificate cards for paper */
    .certificate-card {
        background: white !important;
        color: black !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        page-break-inside: avoid; /* Prevents a card from being cut in half across pages */
        margin-bottom: 20px;
    }
    
    /* Force text to be black for readability */
    .cert-name, .cert-details, .cert-notes, .stat-label {
        color: black !important;
    }
    
    /* Ensure images print clearly */
    .cert-image {
        max-height: 200px;
        display: block;
        margin-top: 10px;
    }
}

/* =========================================
   LICENSE GATE STYLES
   ========================================= */
.license-gate {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    z-index: 9999; /* Sits above absolutely everything */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: white;
    text-align: center;
}
body.dark-mode .license-gate {
    background: linear-gradient(135deg, #0f3460 0%, #000000 100%);
}
.license-gate-content {
    max-width: 450px;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
}
.license-gate h1 { font-size: 24px; margin-bottom: 5px; }
.license-subtitle { opacity: 0.8; margin-bottom: 30px; font-size: 14px; }
.lc-state h2 { font-size: 20px; margin-bottom: 10px; }
.lc-state p { margin-bottom: 20px; line-height: 1.5; opacity: 0.9; }

.lc-input {
    width: 100%; padding: 15px; border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1); color: white; font-size: 16px; margin-bottom: 15px;
}
.lc-input::placeholder { color: rgba(255,255,255,0.6); }
.lc-input:focus { outline: none; border-color: white; }

.lc-btn-primary {
    width: 100%; padding: 15px; background: white; color: #0066cc;
    border: none; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; margin-bottom: 15px;
}
.lc-btn-secondary {
    width: 100%; padding: 15px; background: transparent; color: white;
    border: 2px solid white; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer;
}
.lc-error {
    color: #ffcccc; background: rgba(255,0,0,0.2); padding: 10px;
    border-radius: 6px; font-size: 14px; margin-bottom: 15px;
}
.lc-icon { font-size: 48px; margin-bottom: 15px; }
.lc-footer { font-size: 14px; margin-top: 20px; }
.lc-footer a { color: white; text-decoration: underline; }

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3); border-radius: 50%;
    border-top: 4px solid white; width: 40px; height: 40px;
    animation: spin 1s linear infinite; margin: 0 auto 20px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }