body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 300;
}

.header p {
    margin: 10px 0 0 0;
    opacity: 0.9;
    font-size: 1.1rem;
}

.content {
    padding: 40px;
}

.file-upload-section {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    border-left: 5px solid #28a745;
    margin-bottom: 30px;
    text-align: center;
}

.file-upload {
    position: relative;
    display: inline-block;
    margin: 20px 0;
}

.file-upload input[type=file] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-btn {
    display: inline-block;
    padding: 15px 30px;
    background: #28a745;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.file-upload-btn:hover {
    background: #218838;
    transform: translateY(-2px);
}

.file-status {
    margin-top: 15px;
    padding: 10px 20px;
    border-radius: 5px;
    display: none;
}

.file-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.file-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.loading-container {
    text-align: center;
    padding: 40px;
    background: #f8f9fa;
    border-radius: 10px;
    margin: 20px 0;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #e3e3e3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 1.1rem;
    color: #666;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: #f8f9fa;
    padding: 18px;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #667eea;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 0;
}

.stat-label {
    color: #666;
    margin: 4px 0 0 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-section {
    margin: 30px 0;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    border-left: 5px solid #667eea;
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

#searchInput {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 0.8rem;
    display: none;
}

.search-btn:hover {
    background: #495057;
}

.search-results {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: none;
}

.search-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-item:hover {
    background: #f0f4ff;
}

.search-item:last-child {
    border-bottom: none;
}

.search-code {
    font-family: 'Courier New', monospace;
    background: #e3f2fd;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #1565c0;
}

.search-description {
    margin: 5px 0;
    color: #333;
}

.search-price {
    font-weight: bold;
    color: #27ae60;
    font-size: 1.1rem;
}

.search-details {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}

.highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.preview-table {
    margin-top: 30px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Mobile cards - hidden on desktop by default */
.mobile-table-cards {
    display: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: #2c3e50;
    color: white;
    padding: 15px 10px;
    text-align: left;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
}

tr:nth-child(even) {
    background: #f8f9fa;
}

tr:hover {
    background: #e3f2fd;
}

.price {
    font-weight: bold;
    color: #27ae60;
}

.code {
    font-family: 'Courier New', monospace;
    background: #f1f3f4;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 0.85rem;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.table-controls-right {
    display: flex;
    gap: 15px;
    align-items: center;
}

.table-controls select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-controls select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), 0 2px 4px rgba(0,0,0,0.1);
}

.table-info {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.2s ease;
}

.sortable:hover {
    background: rgba(102, 126, 234, 0.1);
}

.sort-arrow {
    margin-left: 5px;
    font-size: 0.7rem;
    opacity: 0.5;
}

.sort-arrow.active {
    opacity: 1;
    color: #667eea;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
}

.pagination-btn {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    min-width: 40px;
    text-align: center;
}

.pagination-btn:hover:not(.disabled) {
    border-color: #667eea;
    background: #f0f4ff;
}

.pagination-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    margin: 0 15px;
    color: #666;
    font-size: 0.9rem;
}

.instructions {
    background: #e3f2fd;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 5px solid #2196f3;
}

.instructions h3 {
    margin-top: 0;
    color: #1565c0;
}

.instructions ul {
    margin: 0;
    padding-left: 20px;
}

.instructions li {
    margin: 8px 0;
}

.password-section {
    background: #f8f9fa;
    padding: 40px;
    border-radius: 10px;
    border-left: 5px solid #667eea;
    margin-bottom: 30px;
    text-align: center;
    max-width: 500px;
    margin: 30px auto;
}

.password-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

#usernameInput, #passwordInput {
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
    min-width: 200px;
}

#usernameInput:focus, #passwordInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== MOBILE RESPONSIVE IMPROVEMENTS ===== */

/* Mobile First - Small screens (up to 768px) */
@media (max-width: 768px) {
    
    /* Header adjustments */
    .header {
        padding: 20px 15px;
    }
    
    .header h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    .header p {
        font-size: 0.95rem;
    }
    
    /* Content spacing */
    .content {
        padding: 20px 15px;
    }
    
    /* Stats grid - single column on mobile */
    .stats {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-bottom: 25px;
    }
    
    .stat-card {
        padding: 15px 12px;
        text-align: left;
    }
    
    .stat-number {
        font-size: 1.6rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    /* Password section */
    .password-section {
        padding: 25px 15px;
        margin: 20px 0;
    }
    
    .password-container {
        flex-direction: column;
        gap: 12px;
    }
    
    #usernameInput, #passwordInput {
        width: 100%;
        min-width: unset;
        padding: 12px 15px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Search section after controls */
    .search-section {
        padding: 12px 0; /* Added padding for better spacing */
        background: transparent;
        border: none;
        margin: 0;
    }
    
    .search-container {
        position: relative;
        max-width: none;
        margin: 0 15px; /* Match reduced mobile card margins */
    }
    
    #searchInput {
        width: 100%;
        font-size: 16px;
        padding: 8px 40px 8px 12px;
        border: none;
        border-radius: 4px;
        box-sizing: border-box;
        background: white;
        min-height: 44px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        border-left: 2px solid #667eea;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .search-btn {
        position: absolute;
        right: 23px;
        top: 50%;
        transform: translateY(-50%);
        width: 28px;
        height: 28px;
        background: #6c757d;
        color: white;
        border: none;
        border-radius: 4px;
        font-size: 0.8rem;
    }
    
    /* Actions buttons */
    .actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin: 20px 0;
    }
    
    .btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    
    /* Hide traditional table on mobile */
    .preview-table table {
        display: none;
    }
    
    /* Show mobile cards instead */
    .mobile-table-cards {
        display: block;
        margin: 10px 0; /* Changed to give proper spacing */
        padding: 0;
    }
    
    /* Compact mobile list style with proper screen padding */
    .mobile-item-card {
        background: white;
        border-radius: 4px;
        margin: 2px 15px;
        padding: 8px 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        border-left: 2px solid #667eea;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .mobile-item-card:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        background: #f8f9fa;
    }
    
    .mobile-item-left {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-width: 0;
    }
    
    .mobile-item-code {
        font-family: 'Courier New', monospace;
        font-size: 0.8rem;
        font-weight: bold;
        color: #667eea;
        margin-bottom: 2px;
    }
    
    .mobile-item-description {
        font-size: 0.85rem;
        color: #495057;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .mobile-item-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .mobile-item-price {
        font-size: 0.9rem;
        font-weight: bold;
        color: #28a745;
        text-align: right;
        padding: 4px 8px;
        background: #e8f5e8;
        border-radius: 4px;
        min-width: 60px;
    }
    
    .btn-email {
        background: #007bff;
        color: white;
        border: none;
        border-radius: 4px;
        padding: 6px 8px;
        cursor: pointer;
        font-size: 14px;
        transition: background-color 0.3s ease;
        min-width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-email:hover {
        background: #0056b3;
    }
    
    .modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }
    
    .modal-content {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: white;
        padding: 30px;
        border-radius: 10px;
        width: 90%;
        max-width: 500px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
    }
    
    .modal-header h3 {
        margin: 0;
        color: #2c3e50;
    }
    
    .close {
        font-size: 28px;
        font-weight: bold;
        cursor: pointer;
        color: #aaa;
    }
    
    .close:hover {
        color: #000;
    }
    
    .modal-input {
        width: 100%;
        padding: 12px;
        margin: 10px 0;
        border: 2px solid #e0e0e0;
        border-radius: 5px;
        font-size: 14px;
        box-sizing: border-box;
    }
    
    .modal-input:focus {
        outline: none;
        border-color: #667eea;
    }
    
    .modal-buttons {
        display: flex;
        gap: 15px;
        justify-content: flex-end;
        margin-top: 20px;
    }
    
    .btn-modal {
        padding: 12px 24px;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        transition: all 0.3s ease;
    }
    
    .btn-save {
        background: #28a745;
        color: white;
    }
    
    .btn-save:hover {
        background: #218838;
    }
    
    .btn-cancel {
        background: #6c757d;
        color: white;
    }
    
    .btn-cancel:hover {
        background: #5a6268;
    }
    
    /* Empty items message */
    .mobile-no-items {
        text-align: center;
        padding: 40px 20px;
        color: #666;
        font-style: italic;
        background: #f8f9fa;
        margin: 20px; /* Increased margin for better screen padding */
        border-radius: 12px;
        border: 2px dashed #dee2e6;
    }
    
    /* Table controls mobile layout */
    .table-controls {
        flex-direction: column;
        gap: 15px;
        padding: 20px 15px;
        text-align: center;
        background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    }
    
    .table-controls-right {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }
    
    .table-info {
        font-size: 0.9rem;
        color: #495057;
        font-weight: 600;
        padding: 10px 15px;
        background: #e3f2fd;
        border-radius: 8px;
        border-left: 4px solid #2196f3;
    }
    
    .table-controls select {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 10px;
        background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
        border: 2px solid #e0e0e0;
        box-shadow: 0 3px 8px rgba(0,0,0,0.12);
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMiIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDEyIDEyIj48cGF0aCBmaWxsPSIjNjY2IiBkPSJNMTAuMjkzIDMuMjkzTDYgNy41ODZsLTQuMjkzLTQuMjkzYTEgMSAwIDAgMC0xLjQxNCAxLjQxNGw1IDVhMSAxIDAgMCAwIDEuNDE0IDBsNS01YTEgMSAwIDAgMC0xLjQxNC0xLjQxNHoiLz48L3N2Zz4=');
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 40px;
    }
    
    /* Pagination mobile */
    .pagination-controls {
        flex-wrap: wrap;
        padding: 15px;
        gap: 8px;
    }
    
    .pagination-btn {
        min-width: 35px;
        padding: 8px;
        font-size: 0.85rem;
    }
    
    .pagination-info {
        margin: 0;
        text-align: center;
        width: 100%;
        font-size: 0.85rem;
    }
    
    /* Loading improvements */
    .loading-container {
        padding: 25px 15px;
        margin: 15px 0;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
        margin-bottom: 15px;
    }
    
    /* File status */
    .file-status {
        padding: 12px 15px;
        font-size: 0.9rem;
        margin: 15px 0;
    }
    
    /* Instructions */
    .instructions {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .instructions h3 {
        font-size: 1.1rem;
    }
}

/* Tablet adjustments (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .content {
        padding: 30px 25px;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .password-container {
        flex-direction: row;
        justify-content: center;
    }
    
    #usernameInput, #passwordInput {
        min-width: 180px;
    }
}

/* Very small screens (up to 480px) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        border-radius: 10px;
    }
    
    .header {
        padding: 15px 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .content {
        padding: 15px 10px;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    .preview-table {
        margin: 15px -10px;
    }
    
    .preview-table th {
        padding: 6px 3px;
        font-size: 0.7rem;
    }
    
    .preview-table td {
        padding: 6px 3px;
        font-size: 0.75rem;
    }
    
    /* Search highlight in mobile cards */
    .mobile-item-card .highlight {
        background-color: #fff3cd;
        padding: 2px 4px;
        border-radius: 3px;
        font-weight: bold;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* ===== ADMIN PANEL MOBILE IMPROVEMENTS ===== */
@media (max-width: 768px) {
    /* Admin navigation */
    .nav-menu {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }
    
    .nav-menu a {
        width: 100%;
        text-align: center;
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    /* Admin sections */
    .admin-section, .upload-section {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    /* User management table */
    .user-table-container {
        overflow-x: auto;
        margin: 0 -15px;
    }
    
    .user-table {
        min-width: 600px;
        font-size: 0.85rem;
    }
    
    .user-table th,
    .user-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* User form */
    .user-form {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .user-form input,
    .user-form select {
        width: 100%;
        padding: 10px 15px;
        font-size: 16px;
    }
    
    /* File upload admin */
    .file-upload-admin {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .file-upload-admin input[type="file"] {
        padding: 10px;
        font-size: 14px;
    }
    
    /* Modal mobile */
    .modal-content {
        margin: 5% auto;
        width: 90%;
        max-width: 400px;
        padding: 20px;
    }
    
    .modal-content input {
        width: 100%;
        padding: 12px 15px;
        font-size: 16px;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .nav-menu a {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .admin-section, .upload-section {
        padding: 15px 10px;
    }
    
    .user-table {
        font-size: 0.8rem;
    }
    
    .modal-content {
        margin: 10px;
        width: calc(100% - 20px);
        padding: 15px;
    }
}