* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f7fa; }

.sidebar { position: fixed; left: 0; top: 0; width: 260px; height: 100vh; background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); color: white; z-index: 1000; overflow-y: auto; display: flex; flex-direction: column; }
.logo {
    padding: 1.5rem 1rem;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.logo-icon {
    width: 100%;
    height: auto;
    max-width: 220px;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
}
.logo h1 { font-size: 1.5rem; }
.menu { padding: 1rem 0; flex: 1; overflow-y: auto; }

/* Menu Items */
.menu-item {
    padding: 0.875rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #cbd5e0;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}
.menu-item:hover { background: rgba(255,255,255,0.08); }
.menu-item.active { background: rgba(99,102,241,0.15); color: white; border-left-color: #6366f1; }

.menu-icon {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.menu-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Menu Sections (Collapsible) */
.menu-section {
    margin: 0.5rem 0;
}

.menu-section-header {
    padding: 0.875rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.menu-section-header:hover {
    background: rgba(255,255,255,0.05);
    color: #e2e8f0;
}

.menu-arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: #64748b;
}

.menu-section-items {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 1;
}

.menu-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Submenu Items */
.submenu-item {
    padding-left: 2.5rem !important;
    font-size: 0.85rem;
    border-left: none !important;
    position: relative;
}

.submenu-item::before {
    content: '';
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #475569;
    transition: all 0.2s ease;
}

.submenu-item:hover::before {
    background: #6366f1;
}

.submenu-item.active::before {
    background: #6366f1;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.main { margin-left: 260px; padding: 2rem; min-height: 100vh; }
.header { background: white; padding: 1.5rem 2rem; border-radius: 12px; margin-bottom: 2rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.header h2 { color: #1e293b; font-size: 1.75rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card { background: white; padding: 1.25rem; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.card-title { color: #64748b; font-size: 0.75rem; text-transform: uppercase; margin-bottom: 0.5rem; }
.card-value { font-size: 1.75rem; font-weight: 700; color: #1e293b; }

.section { background: white; padding: 1.5rem; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 600; color: #1e293b; margin-bottom: 1rem; }

.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th { background: #f8fafc; padding: 0.75rem; text-align: left; font-weight: 600; color: #475569; }
.table td { padding: 0.75rem; border-top: 1px solid #e2e8f0; }
.table tr:hover { background: #f8fafc; }

.btn { background: #6366f1; color: white; padding: 0.625rem 1.25rem; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; margin: 0.25rem; }
.btn:hover { background: #4f46e5; }

.upload-box { border: 2px dashed #cbd5e0; border-radius: 8px; padding: 1.5rem; text-align: center; margin: 1rem 0; }
.loading { text-align: center; padding: 3rem; color: #64748b; }
.page { display: none; }
.page.active { display: block; }

/* ========================================
   IMPORT PAGE STYLES
   ======================================== */

.import-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.import-header {
    text-align: center;
    margin-bottom: 2rem;
}

.import-header h2 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1rem;
}

.period-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.period-selector label {
    font-weight: 600;
    color: #2c3e50;
}

.period-selector select {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

.import-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.import-step {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 4px solid #3498db;
    transition: transform 0.2s;
}

.import-step:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.import-step.required {
    border-left-color: #e74c3c;
}

.import-step.optional {
    border-left-color: #95a5a6;
}

.step-number {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.step-content {
    flex: 1;
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.step-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-required {
    background: #fee;
    color: #e74c3c;
}

.badge-optional {
    background: #f0f0f0;
    color: #7f8c8d;
}

.badge-info {
    background: #e3f2fd;
    color: #2196f3;
}

.badge-success {
    background: #e8f5e9;
    color: #4caf50;
}

.badge-error {
    background: #ffebee;
    color: #f44336;
}

.step-description {
    color: #7f8c8d;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.step-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.file-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem;
    border: 2px dashed #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.file-input:hover {
    border-color: #3498db;
}

.upload-result {
    margin-top: 1rem;
}

.upload-result p {
    padding: 0.75rem;
    border-radius: 4px;
    margin: 0;
}

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

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

.upload-result .loading {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.import-history {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.import-history h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table thead {
    background: #f8f9fa;
}

.history-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #dee2e6;
}

.history-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

.history-table tbody tr:hover {
    background: #f8f9fa;
}

.no-data {
    text-align: center;
    color: #7f8c8d;
    padding: 2rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #3498db;
}

@media (max-width: 768px) {
    .import-step {
        flex-direction: column;
    }
    
    .step-number {
        align-self: flex-start;
    }
    
    .step-actions {
        flex-direction: column;
    }
    
    .file-input {
        width: 100%;
    }
}

/* Frequency badges */
.badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge-frequency {
    font-size: 0.8rem;
}

.badge-zilnic {
    background: #fff3cd;
    color: #856404;
}

.badge-saptamanal {
    background: #cfe2ff;
    color: #084298;
}

.badge-lunar {
    background: #d1e7dd;
    color: #0f5132;
}

/* ========================================
   PAYMENTS TABLES (sub calendar)
   ======================================== */

.payments-tables-section {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.payments-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.payments-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s;
}

.payments-tab:hover {
    color: #1e293b;
    background: #f8fafc;
}

.payments-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.payments-table-container {
    overflow-x: auto;
}

.payments-list-table {
    width: 100%;
    border-collapse: collapse;
}

.payments-list-table thead {
    background: #f8fafc;
}

.payments-list-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.9rem;
}

.payments-list-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}

.payment-row-item:hover {
    background: #f8fafc;
}

.amount-income {
    color: #10b981;
    font-weight: 600;
}

.amount-expense {
    color: #ef4444;
    font-weight: 600;
}

.table-footer {
    padding: 1rem;
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

@media (max-width: 768px) {
    .payments-list-table {
        font-size: 0.8rem;
    }
    
    .payments-list-table th,
    .payments-list-table td {
        padding: 0.5rem;
    }
}

/* ========================================
   PAYMENTS TODO SECTION
   ======================================== */

.payments-todo-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.todo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.todo-header h3 {
    margin: 0;
    color: #1e293b;
    font-size: 1.2rem;
}

.badge-success {
    background: #10b981;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-danger {
    background: #ef4444;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.todo-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.todo-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    transition: all 0.2s;
}

.todo-item:hover {
    background: #f1f5f9;
    transform: translateX(4px);
}

.todo-item.overdue {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.todo-checkbox {
    margin-right: 1rem;
}

.todo-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.todo-content {
    flex: 1;
}

.todo-partner {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.todo-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #64748b;
}

.todo-amount {
    font-weight: 600;
    color: #ef4444;
}

.todo-separator {
    color: #cbd5e1;
}

.todo-due.overdue-text {
    color: #ef4444;
    font-weight: 600;
}

.todo-invoice {
    font-family: monospace;
    color: #64748b;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .todo-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .todo-checkbox {
        margin-bottom: 0.5rem;
    }
}

/* ==================== USER MANAGEMENT ==================== */

.tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-weight: 500;
}

.tab:hover {
    background: #f3f4f6;
}

.tab.active {
    border-bottom-color: #6366f1;
    color: #6366f1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table thead {
    background: #f8f9fa;
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #4b5563;
    border-bottom: 2px solid #e5e7eb;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.data-table tr:hover {
    background: #f9fafb;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin: 2px;
}

.badge-admin {
    background: #fee2e2;
    color: #991b1b;
}

.badge-role {
    background: #dbeafe;
    color: #1e40af;
}

.status-active {
    color: #059669;
    font-weight: 500;
}

.status-inactive {
    color: #dc2626;
    font-weight: 500;
}

.text-muted {
    color: #9ca3af;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
    margin-right: 4px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.2);
}

.btn-icon.btn-delete:hover {
    filter: brightness(0.8);
}

/* Roles Grid */

.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.role-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s;
}

.role-card:hover {
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

.role-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.role-header h3 {
    margin: 0;
    color: #1f2937;
}

.role-actions {
    display: flex;
    gap: 4px;
}

.role-description {
    color: #6b7280;
    font-size: 0.875rem;
    margin: 10px 0;
    min-height: 40px;
}

.role-stats {
    display: flex;
    gap: 16px;
    margin: 12px 0;
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 0.875rem;
}

.role-permissions {
    margin-top: 12px;
}

.perm-badge {
    display: inline-block;
    padding: 4px 8px;
    margin: 2px;
    background: #ede9fe;
    color: #5b21b6;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: help;
}

/* Modal Styles */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #4b5563;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: #f3f4f6;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin: 0;
    color: #1f2937;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
    font-style: italic;
}

.error {
    background: #fee2e2;
    color: #991b1b;
    padding: 16px;
    border-radius: 8px;
    margin: 20px 0;
}

/* Hide users menu for non-admins */
#menu-users.hidden {
    display: none;
}

/* Logout Button */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.logout-button {
    width: 100%;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
}

.logout-button:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fff;
}

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

@media (max-width: 768px) {
    /* Sidebar - Hidden by default on mobile, shown with toggle */
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left 0.3s ease;
        z-index: 2000;
    }

    .sidebar.open {
        left: 0;
    }

    /* Menu sections on mobile */
    .menu-section-header {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }

    .menu-item {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    .submenu-item {
        padding-left: 2rem !important;
    }

    .submenu-item::before {
        left: 1rem;
    }

    .menu-icon {
        width: 20px;
        font-size: 1rem;
    }

    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1999;
        background: #6366f1;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 0.75rem;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        font-size: 1.5rem;
        line-height: 1;
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1998;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Main content - full width on mobile */
    .main {
        margin-left: 0;
        padding: 4rem 1rem 1rem 1rem;
    }
    
    /* Page header - stack vertically */
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch !important;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .page-header button,
    .page-header .btn-primary {
        width: 100%;
    }
    
    /* Tables - horizontal scroll */
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
        font-size: 0.875rem;
    }
    
    /* Stats grid - single column */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Roles grid - single column */
    .roles-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Tabs - horizontal scroll if needed */
    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .tab {
        white-space: nowrap;
        font-size: 0.875rem;
        padding: 10px 16px;
    }
    
    /* Modals - full screen on mobile */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 1rem auto;
        max-height: 95vh;
    }
    
    /* Forms - stack vertically */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Buttons - larger touch targets */
    .btn-primary,
    .btn-secondary,
    .btn-small {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .btn-icon {
        font-size: 1.5rem;
        padding: 0.5rem;
    }
    
    /* Section header - stack vertically */
    .section-header {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .section-header button {
        width: 100%;
    }
    
    /* Checkbox groups - better spacing */
    .checkbox-group {
        gap: 12px;
    }
    
    .checkbox-label {
        padding: 12px;
    }
    
    /* Hide some columns in tables on very small screens */
    @media (max-width: 480px) {
        .data-table .hide-mobile {
            display: none;
        }
    }
}

/* Desktop - hide mobile toggle */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }
}

/* ==================== ADDITIONAL MOBILE OPTIMIZATIONS ==================== */

/* Better touch targets */
@media (max-width: 768px) {
    /* Increase all interactive elements */
    button, a, .menu-item, input, select {
        min-height: 44px; /* iOS recommended minimum */
    }
    
    /* Invoices/Payments/etc tables - card layout on mobile */
    @media (max-width: 640px) {
        .data-table thead {
            display: none;
        }
        
        .data-table tr {
            display: block;
            margin-bottom: 1rem;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            padding: 1rem;
            background: white;
        }
        
        .data-table td {
            display: block;
            text-align: left !important;
            padding: 0.5rem 0;
            border: none;
        }
        
        .data-table td:before {
            content: attr(data-label);
            font-weight: 600;
            display: inline-block;
            min-width: 120px;
            color: #6b7280;
        }
    }
    
    /* Stats cards - better spacing */
    .stat-card {
        padding: 1.25rem !important;
    }
    
    /* Calendar - responsive */
    #monthCalendar {
        font-size: 0.75rem;
    }
    
    /* Charts - responsive */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Landscape phone */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 220px;
    }
    
    .sidebar.open {
        left: 0;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .page-header h1 {
        font-size: 1.25rem;
    }
    
    .btn-primary,
    .btn-secondary {
        font-size: 0.875rem;
        padding: 0.625rem 1rem;
    }
}

/* ==================== DASHBOARD MOBILE FIX ==================== */

@media (max-width: 768px) {
    /* Dashboard stats - single column */
    .stats {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem !important;
    }
    
    .stat-card h3 {
        font-size: 0.875rem;
    }
    
    .stat-card .value {
        font-size: 1.5rem !important;
    }
    
    /* Dashboard charts - stack vertically */
    .charts-container,
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    /* Chart containers */
    .chart-container {
        min-height: 250px !important;
    }
    
    /* Urgent items list */
    .urgent-list {
        font-size: 0.875rem;
    }
    
    .urgent-item {
        padding: 0.75rem !important;
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .urgent-item .date {
        margin-top: 0.5rem;
        font-size: 0.75rem;
    }
}

/* ==================== MODAL RESPONSIVE FIX ==================== */

@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100vh;
        margin: 0 !important;
        border-radius: 0 !important;
        max-height: 100vh;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        padding: 1rem;
        border-bottom: 2px solid #e5e7eb;
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
        margin: 0;
    }
    
    .modal-close {
        font-size: 1.75rem;
        padding: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        max-height: calc(100vh - 140px);
    }
    
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        padding: 1rem;
        border-top: 2px solid #e5e7eb;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer button {
        width: 100%;
        margin: 0;
    }
    
    /* Form groups in modals */
    .modal-body .form-group {
        margin-bottom: 1.25rem;
    }
    
    .modal-body .form-group label {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }
    
    .modal-body input,
    .modal-body select,
    .modal-body textarea {
        font-size: 16px !important; /* Prevent zoom */
        padding: 0.75rem;
    }
    
    /* Checkbox groups in modals */
    .modal-body .checkbox-group {
        max-height: 300px;
        overflow-y: auto;
    }
    
    .modal-body .checkbox-label {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* ==================== PAYMENTS PAGE MOBILE FIX ==================== */

@media (max-width: 768px) {
    /* Payment filters - stack vertically */
    .filters,
    .payment-filters {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .filters select,
    .filters input {
        width: 100% !important;
        font-size: 16px;
    }
    
    /* Payment summary cards */
    .payment-summary {
        grid-template-columns: 1fr !important;
    }
    
    .payment-card {
        padding: 1rem;
    }
    
    .payment-card h3 {
        font-size: 0.875rem;
    }
    
    .payment-card .amount {
        font-size: 1.25rem;
    }
    
    /* Payment table - card layout */
    .payments-table {
        display: block;
    }
    
    .payments-table thead {
        display: none;
    }
    
    .payments-table tbody {
        display: block;
    }
    
    .payments-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1rem;
        background: white;
    }
    
    .payments-table td {
        display: block;
        text-align: left !important;
        padding: 0.5rem 0;
        border: none;
    }
    
    .payments-table td:before {
        content: attr(data-label);
        font-weight: 600;
        display: inline-block;
        min-width: 100px;
        color: #6b7280;
        margin-right: 0.5rem;
    }
    
    /* Action buttons in table */
    .payments-table .actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .payments-table .actions button {
        width: 100%;
    }
}

/* ==================== ADDITIONAL MODAL IMPROVEMENTS ==================== */

@media (max-width: 640px) {
    /* Very small screens - full screen modals */
    .modal-content {
        border-radius: 0 !important;
    }
    
    /* Permission groups - compact */
    .modal-body .perm-badge {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
    
    /* Role cards in modal */
    .modal-body .role-card {
        padding: 0.75rem;
    }
    
    .modal-body .role-header h3 {
        font-size: 1rem;
    }
}

/* ==================== LANDSCAPE PHONE FIX ==================== */

@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 100vh;
    }
    
    .modal-body {
        max-height: calc(100vh - 120px);
    }
}

/* ==================== INVOICES, RESERVATIONS, PARTNERS MOBILE ==================== */

@media (max-width: 640px) {
    /* Generic table to card conversion */
    table:not(.data-table) {
        display: block;
    }
    
    table:not(.data-table) thead {
        display: none;
    }
    
    table:not(.data-table) tbody {
        display: block;
    }
    
    table:not(.data-table) tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        padding: 1rem;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    table:not(.data-table) td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
        font-size: 0.875rem;
    }
    
    table:not(.data-table) td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        margin-right: 1rem;
    }
    
    /* Buttons in mobile tables */
    table td .btn-small {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Stats in table cells */
    table td strong {
        font-size: 1rem;
        color: #10b981;
    }
}

/* ==================== PAGE HEADER IMPROVEMENTS ==================== */

@media (max-width: 768px) {
    .header,
    .page-header {
        padding: 1rem 0;
        margin-bottom: 1.5rem;
    }
    
    .header h1,
    .header h2,
    .page-header h1,
    .page-header h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .header button,
    .page-header button {
        width: 100%;
        padding: 0.875rem;
        font-size: 1rem;
    }
}

/* ==================== STATS CARDS ENHANCEMENT ==================== */

@media (max-width: 768px) {
    .stat-card,
    .stats-card {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .stat-card .icon,
    .stats-card .icon {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .stat-card .label,
    .stats-card .label {
        font-size: 0.875rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #6b7280;
    }
    
    .stat-card .value,
    .stats-card .value {
        font-size: 1.75rem;
        font-weight: 700;
        color: #10b981;
    }
    
    .stat-card .change,
    .stats-card .change {
        font-size: 0.75rem;
    }
}

/* ==================== FORM IMPROVEMENTS FOR MOBILE ==================== */

@media (max-width: 768px) {
    /* Date inputs side by side when space allows */
    .form-row {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .form-row .form-group {
        flex: 1;
        min-width: 140px;
    }
    
    /* Search boxes */
    input[type="search"],
    input[placeholder*="Caută"],
    input[placeholder*="Search"] {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px;
        border-radius: 8px;
    }
    
    /* Select dropdowns */
    select {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px;
        border-radius: 8px;
        background-color: white;
    }
}

/* ==================== DASHBOARD SPECIFIC FIXES ==================== */

@media (max-width: 768px) {
    /* Dashboard content wrapper */
    #dashboard-content {
        padding: 0.5rem;
    }
    
    /* Dashboard stats - force single column */
    #dashboard-content > div:first-child,
    #dashboard-content .stats,
    div[style*="grid-template-columns: repeat(4"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    /* Dashboard stat boxes */
    #dashboard-content > div:first-child > div,
    .stats > div {
        padding: 1rem !important;
        border-radius: 8px;
    }
    
    /* Charts section - stack vertically */
    #dashboard-content > div:nth-child(2),
    div[style*="display:grid"][style*="grid-template-columns: 1fr 1fr"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Chart containers */
    #dashboard-content canvas {
        max-height: 250px !important;
    }
    
    /* Urgent items section */
    #dashboard-content > div:last-child {
        margin-top: 1rem;
    }
    
    /* Urgent items cards */
    #dashboard-content .urgent-card,
    div[style*="background:white;padding"] {
        padding: 0.75rem !important;
        margin-bottom: 0.5rem;
    }
}

/* ==================== PAYMENTS PAGE SPECIFIC ==================== */

@media (max-width: 768px) {
    /* Payments header with filters */
    #payments > div:first-child {
        padding: 0.5rem;
    }
    
    /* Payment type tabs */
    #payments .tabs,
    div[style*="display:flex;gap:1rem;margin-bottom"] {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        gap: 0.5rem !important;
        padding-bottom: 0.5rem;
    }
    
    /* Payment type tab buttons */
    #payments .tabs button,
    #payments button[onclick*="filterPayments"] {
        white-space: nowrap;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Payment filters row */
    #payments select,
    #payments input[type="date"] {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }
    
    /* Payment summary boxes */
    #payments > div[style*="grid-template-columns"],
    div.payment-summary {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}

/* ==================== MODALS DETAIL FIX ==================== */

@media (max-width: 768px) {
    /* Invoice/Reservation detail modals */
    #invoiceModal .modal-content,
    #departureModal .modal-content,
    div[id$="Modal"] .modal-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Detail sections in modals */
    .modal-content section,
    .modal-content > div > div {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    /* Info grid in modals - single column */
    .modal-content div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Labels and values in details */
    .modal-content label,
    .modal-content strong {
        font-size: 0.875rem;
        display: block;
        margin-bottom: 0.25rem;
        color: #6b7280;
    }
    
    .modal-content p,
    .modal-content span {
        font-size: 0.9375rem;
    }
}

/* ========================================
   IMPORT & SYNC SETTINGS STYLES
   ======================================== */

.import-container { max-width: 1200px; }
.import-header { margin-bottom: 1.5rem; }
.import-header h2 { color: #1e293b; font-size: 1.5rem; margin-bottom: 0.5rem; }

.import-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem; }
.tab-btn { padding: 0.75rem 1.5rem; border: none; background: transparent; color: #64748b; cursor: pointer; font-weight: 500; border-radius: 8px 8px 0 0; transition: 0.2s; }
.tab-btn:hover { background: #f1f5f9; color: #1e293b; }
.tab-btn.active { background: #6366f1; color: white; }

.tab-content { display: none; }
.tab-content.active { display: block; }

.status-card { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border: 1px solid #86efac; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; align-items: center; }
.status-item { display: flex; flex-direction: column; gap: 0.25rem; }
.status-item label { font-size: 0.75rem; color: #166534; text-transform: uppercase; font-weight: 600; }
.status-item span { font-size: 1rem; color: #14532d; }
.sync-progress { margin-top: 1rem; padding: 0.75rem; background: rgba(255,255,255,0.7); border-radius: 8px; display: flex; align-items: center; gap: 0.5rem; color: #166534; }

.settings-card { background: white; border-radius: 12px; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 1.5rem; }
.settings-card h3 { color: #1e293b; font-size: 1.1rem; margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid #e2e8f0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: #475569; margin-bottom: 0.5rem; }
.form-group input[type="text"], .form-group input[type="url"], .form-group input[type="password"], .form-group input[type="email"], .form-group input[type="number"] {
    width: 100%; padding: 0.75rem; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.9rem;
}
.form-group input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.form-group small { display: block; font-size: 0.75rem; color: #94a3b8; margin-top: 0.25rem; }

.time-input { display: flex; align-items: center; gap: 0.5rem; }
.time-input input { text-align: center; }

.checkbox-group { display: flex; align-items: center; gap: 0.5rem; padding-top: 1.5rem; }
.checkbox-group input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.checkbox-group label { cursor: pointer; font-weight: 500; }

.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; }

.import-steps { display: flex; flex-direction: column; gap: 1rem; }
.import-step { background: white; border-radius: 12px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.step-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.step-number { width: 32px; height: 32px; background: #6366f1; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.step-header h4 { flex: 1; margin: 0; color: #1e293b; }
.step-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.75rem; }
.step-actions input[type="file"] { flex: 1; }
.upload-result { margin-top: 0.5rem; font-size: 0.85rem; }

.logs-container { background: white; border-radius: 12px; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.logs-content { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 8px; font-size: 0.8rem; max-height: 500px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; margin-top: 1rem; }

.btn-success { background: #10b981; }
.btn-success:hover { background: #059669; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }

.badge { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-required { background: #fef3c7; color: #92400e; }
.badge-optional { background: #f1f5f9; color: #475569; }

.text-success { color: #10b981; }
.text-error { color: #ef4444; }
.no-data { text-align: center; padding: 2rem; color: #94a3b8; }
.info-message { background: #f0f9ff; border: 1px solid #bae6fd; color: #0369a1; padding: 1rem; border-radius: 8px; }

.spinner { width: 16px; height: 16px; border: 2px solid #e2e8f0; border-top-color: #6366f1; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.data-table th { background: #f8fafc; padding: 0.875rem 1rem; text-align: left; font-weight: 600; color: #475569; font-size: 0.8rem; text-transform: uppercase; }
.data-table td { padding: 0.875rem 1rem; border-top: 1px solid #e2e8f0; font-size: 0.9rem; }
.data-table tr:hover { background: #f8fafc; }

/* ========================================
   CONTACT TOOLTIP STYLES
   ======================================== */
.contact-tooltip {
    position: relative;
    cursor: pointer;
}

.contact-tooltip[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: pre-line;
    min-width: 200px;
    max-width: 300px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
    text-align: left;
    line-height: 1.5;
}

.contact-tooltip[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #1e293b;
    margin-bottom: -16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1001;
}

.contact-tooltip:hover::after,
.contact-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

.contact-tooltip:hover::after {
    bottom: calc(100% + 8px);
}

.contact-tooltip:hover::before {
    margin-bottom: -8px;
}

/* Contact badge pentru restanțe */
.contact-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: #dbeafe;
    border-radius: 4px;
    font-size: 0.7rem;
    color: #1e40af;
    margin-left: 0.5rem;
    cursor: pointer;
}

.contact-badge:hover {
    background: #bfdbfe;
}

/* Hover shadow pentru carduri clicabile */
.hover-shadow:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* ==================== RESERVATIONS PAGE MOBILE ==================== */

@media (max-width: 768px) {
    /* Reservations header */
    #reservations > div:first-child {
        padding: 0.5rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Reservations filters */
    #reservations .filters,
    #reservations div[style*="display:flex"][style*="gap"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
        width: 100%;
    }
    
    #reservations select,
    #reservations input[type="text"],
    #reservations input[type="date"] {
        width: 100% !important;
        font-size: 16px;
        padding: 0.75rem;
    }
    
    /* Reservations table as cards */
    #reservations table {
        display: block;
    }
    
    #reservations table thead {
        display: none;
    }
    
    #reservations table tbody {
        display: block;
    }
    
    #reservations table tr {
        display: block;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    #reservations table td {
        display: block;
        padding: 0.375rem 0;
        border: none;
        text-align: left !important;
    }
    
    #reservations table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        display: inline-block;
        min-width: 100px;
        font-size: 0.75rem;
        text-transform: uppercase;
    }
    
    /* Reservation card emphasis */
    #reservations table td:first-child {
        font-size: 1.1rem;
        font-weight: 700;
        color: #1e293b;
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #f1f5f9;
    }
}

/* ==================== INVOICES PAGE MOBILE ==================== */

@media (max-width: 768px) {
    /* Invoices header */
    #invoices > div:first-child {
        padding: 0.5rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Invoice type tabs */
    #invoices .tabs,
    #invoices div[style*="gap:1rem"] {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        gap: 0.5rem !important;
        padding-bottom: 0.5rem;
    }
    
    /* Invoices table as cards */
    #invoices table {
        display: block;
    }
    
    #invoices table thead {
        display: none;
    }
    
    #invoices table tbody {
        display: block;
    }
    
    #invoices table tr {
        display: block;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    #invoices table td {
        display: block;
        padding: 0.375rem 0;
        border: none;
        text-align: left !important;
    }
    
    #invoices table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        display: inline-block;
        min-width: 100px;
        font-size: 0.75rem;
        text-transform: uppercase;
    }
    
    /* Invoice number emphasis */
    #invoices table td:first-child {
        font-size: 1.1rem;
        font-weight: 700;
        color: #1e293b;
        margin-bottom: 0.5rem;
    }
}

/* ==================== PARTNERS PAGE MOBILE ==================== */

@media (max-width: 768px) {
    /* Partners header */
    #partners > div:first-child {
        padding: 0.5rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Partners table as cards */
    #partners table {
        display: block;
    }
    
    #partners table thead {
        display: none;
    }
    
    #partners table tbody {
        display: block;
    }
    
    #partners table tr {
        display: block;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    #partners table td {
        display: block;
        padding: 0.375rem 0;
        border: none;
        text-align: left !important;
    }
    
    #partners table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        display: inline-block;
        min-width: 100px;
        font-size: 0.75rem;
        text-transform: uppercase;
    }
}

/* ==================== ADVANCES PAGE MOBILE ==================== */

@media (max-width: 768px) {
    /* Advances header */
    #advances > div:first-child {
        padding: 0.5rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Advances filters */
    #advances .filters,
    #advances select,
    #advances input[type="text"],
    #advances input[type="date"] {
        width: 100% !important;
        font-size: 16px;
    }
    
    /* Advances summary cards */
    #advances div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    /* Advances table as cards */
    #advances table {
        display: block;
    }
    
    #advances table thead {
        display: none;
    }
    
    #advances table tbody {
        display: block;
    }
    
    #advances table tr {
        display: block;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    #advances table td {
        display: block;
        padding: 0.375rem 0;
        border: none;
        text-align: left !important;
    }
    
    #advances table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        display: inline-block;
        min-width: 100px;
        font-size: 0.75rem;
        text-transform: uppercase;
    }
}

/* ==================== DEPARTURES PAGE MOBILE ==================== */

@media (max-width: 768px) {
    /* Departures header */
    #departures > div:first-child {
        padding: 0.5rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Calendar in departures */
    #departures .calendar-view {
        overflow-x: auto;
    }
    
    /* Departures list cards */
    #departures .departure-card,
    #departures div[style*="background:white;padding"] {
        padding: 0.75rem !important;
        margin-bottom: 0.75rem;
    }
    
    #departures table {
        display: block;
    }
    
    #departures table thead {
        display: none;
    }
    
    #departures table tbody {
        display: block;
    }
    
    #departures table tr {
        display: block;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    #departures table td {
        display: block;
        padding: 0.375rem 0;
        border: none;
        text-align: left !important;
    }
    
    #departures table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        display: inline-block;
        min-width: 100px;
        font-size: 0.75rem;
        text-transform: uppercase;
    }
}

/* ==================== USERS PAGE MOBILE ==================== */

@media (max-width: 768px) {
    /* Users header */
    #users > div:first-child {
        padding: 0.5rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    /* User cards */
    #users .user-card {
        padding: 0.75rem;
    }
    
    /* Users table as cards */
    #users table {
        display: block;
    }
    
    #users table thead {
        display: none;
    }
    
    #users table tbody {
        display: block;
    }
    
    #users table tr {
        display: block;
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    
    #users table td {
        display: block;
        padding: 0.375rem 0;
        border: none;
        text-align: left !important;
    }
}

/* ==================== SETTINGS PAGE MOBILE ==================== */

@media (max-width: 768px) {
    /* Settings container */
    #settings {
        padding: 0.5rem;
    }
    
    /* Settings tabs */
    .import-tabs,
    #settings .tabs {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        gap: 0.25rem !important;
        padding: 0 0 0.5rem 0;
        margin: 0 -0.5rem;
        padding: 0 0.5rem 0.5rem;
    }
    
    .tab-btn {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
    
    /* Settings cards */
    .settings-card {
        padding: 1rem;
    }
    
    /* Form grid in settings */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Buttons in settings */
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    /* Log viewer */
    #settings pre,
    .log-viewer {
        font-size: 0.7rem;
        max-height: 250px;
    }
}

/* ==================== DETAIL PAGES MOBILE ==================== */

@media (max-width: 768px) {
    /* Invoice details, Reservation details, Partner details */
    #invoice-details,
    #reservation-details,
    #partner-details {
        padding: 0.5rem;
    }
    
    /* Back button */
    #invoice-details button[onclick*="back"],
    #reservation-details button[onclick*="back"],
    #partner-details button[onclick*="back"] {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    /* Detail sections */
    #invoice-details section,
    #reservation-details section,
    #partner-details section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    /* Info grids in detail pages */
    #invoice-details div[style*="display:grid"],
    #reservation-details div[style*="display:grid"],
    #partner-details div[style*="display:grid"] {
        grid-template-columns: 1fr !important;
    }
}

/* ==================== GENERAL TABLE IMPROVEMENTS ==================== */

@media (max-width: 768px) {
    /* All tables - improve touch targets */
    table button,
    table a {
        min-height: 40px;
        min-width: 40px;
        padding: 0.5rem 0.75rem;
    }
    
    /* Amount columns - make them stand out */
    table td[data-label*="Sumă"],
    table td[data-label*="Total"],
    table td[data-label*="Valoare"],
    table td[data-label*="Restant"] {
        font-size: 1.1rem;
        font-weight: 700;
    }
    
    /* Positive amounts */
    table td[data-label*="Încasat"],
    table td[data-label*="Plătit"] {
        color: #059669;
    }
    
    /* Negative amounts */
    table td[data-label*="Restant"],
    table td[data-label*="Datorat"] {
        color: #dc2626;
    }
}

/* ==================== TOUCH-FRIENDLY IMPROVEMENTS ==================== */

@media (max-width: 768px) {
    /* All clickable elements */
    [onclick],
    button,
    a,
    .menu-item,
    .clickable {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
    
    /* Better button spacing */
    .button-group,
    .actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .button-group button,
    .actions button {
        width: 100%;
    }
    
    /* Prevent text selection on interactive elements */
    button, a, .menu-item {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ==================== MOBILE TABLE FIX WITHOUT DATA-LABEL ==================== */
/* Uses nth-child to add labels automatically for common table structures */

@media (max-width: 768px) {
    /* Generic mobile table card layout */
    .page table:not(.no-mobile) {
        display: block !important;
    }
    
    .page table:not(.no-mobile) thead {
        display: none !important;
    }
    
    .page table:not(.no-mobile) tbody {
        display: block !important;
    }
    
    .page table:not(.no-mobile) tr {
        display: block !important;
        background: white !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 12px !important;
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    }
    
    .page table:not(.no-mobile) td {
        display: block !important;
        padding: 0.375rem 0 !important;
        border: none !important;
        text-align: left !important;
    }
    
    /* First cell as card header */
    .page table:not(.no-mobile) tr td:first-child {
        font-size: 1.1rem !important;
        font-weight: 700 !important;
        color: #1e293b !important;
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.75rem !important;
        border-bottom: 1px solid #f1f5f9 !important;
    }
    
    /* Amount cells styling */
    .page table td[style*="color:#10b981"],
    .page table td[style*="color:#059669"],
    .page table td[style*="color:#ef4444"],
    .page table td[style*="color:#dc2626"],
    .page table td[style*="font-weight:700"] {
        font-size: 1rem !important;
    }
    
    /* Status badges */
    .page table td span[style*="border-radius"] {
        display: inline-block !important;
        margin-top: 0.25rem !important;
    }
    
    /* Hide some columns on mobile */
    .hide-mobile,
    .mobile-hidden {
        display: none !important;
    }
}

/* Make sure detail modals show full screen */
@media (max-width: 768px) {
    div[style*="position:fixed"][style*="z-index"] {
        padding: 0 !important;
    }
    
    div[style*="position:fixed"][style*="z-index"] > div {
        max-width: 100vw !important;
        width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        overflow-y: auto !important;
    }
}

/* ==================== NOTIFICATIONS SYSTEM ==================== */

.notifications-bell {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    z-index: 1500;
    transition: all 0.3s ease;
}

.notifications-bell:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.notifications-bell .bell-icon {
    font-size: 1.25rem;
    animation: none;
}

.notifications-bell.has-urgent .bell-icon {
    animation: bellShake 0.5s ease-in-out infinite;
}

@keyframes bellShake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(10deg); }
    75% { transform: rotate(-10deg); }
}

.notifications-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

.notifications-dropdown {
    position: fixed;
    top: 70px;
    right: 1rem;
    width: 380px;
    max-width: calc(100vw - 2rem);
    max-height: 70vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1600;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.notifications-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
}

.notifications-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.notifications-header .close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.notifications-header .close-btn:hover {
    background: rgba(255,255,255,0.3);
}

.notifications-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.notification-item:hover {
    background: #f8fafc;
}

.notification-item.urgency-high {
    background: #fef2f2;
    border-left-color: #ef4444;
}

.notification-item.urgency-medium {
    background: #fffbeb;
    border-left-color: #f59e0b;
}

.notification-item.urgency-low {
    background: #f0fdf4;
    border-left-color: #10b981;
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.notification-item.type-departure .notification-icon {
    background: #dbeafe;
}

.notification-item.type-arrival .notification-icon {
    background: #dcfce7;
}

/* Invoice due (încasări de la clienți) - verde/albastru */
.notification-item.type-invoice_due {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0f9ff 100%);
    border-left-color: #10b981;
}
.notification-item.type-invoice_due.urgency-high {
    background: linear-gradient(135deg, #d1fae5 0%, #dbeafe 100%);
    border-left-color: #059669;
}
.notification-item.type-invoice_due .notification-icon {
    background: #d1fae5;
    color: #059669;
}
.notification-item.type-invoice_due .notification-title {
    color: #047857;
}
.notification-item.type-invoice_due .notification-detail {
    color: #059669;
    font-weight: 600;
}

/* Payment due (plăți către furnizori) - portocaliu/roșu */
.notification-item.type-payment_due {
    background: linear-gradient(135deg, #fff7ed 0%, #fef2f2 100%);
    border-left-color: #f97316;
}
.notification-item.type-payment_due.urgency-high {
    background: linear-gradient(135deg, #ffedd5 0%, #fee2e2 100%);
    border-left-color: #ea580c;
}
.notification-item.type-payment_due .notification-icon {
    background: #ffedd5;
    color: #ea580c;
}
.notification-item.type-payment_due .notification-title {
    color: #c2410c;
}
.notification-item.type-payment_due .notification-detail {
    color: #ea580c;
    font-weight: 600;
}

.notification-item.type-invoice_overdue .notification-icon {
    background: #fee2e2;
}

.notification-body {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.notification-message {
    color: #475569;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-detail {
    color: #64748b;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.notifications-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.notifications-empty .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.notifications-summary {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.summary-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.summary-badge.high {
    background: #fee2e2;
    color: #dc2626;
}

.summary-badge.medium {
    background: #fef3c7;
    color: #d97706;
}

.summary-badge.low {
    background: #dcfce7;
    color: #059669;
}

/* Mobile responsive notifications */
@media (max-width: 768px) {
    .notifications-bell {
        top: 0.5rem;
        right: 4rem;
        width: 40px;
        height: 40px;
    }
    
    .notifications-dropdown {
        top: 60px;
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
        max-height: 80vh;
    }
    
    .notification-item {
        padding: 0.75rem;
    }
    
    .notification-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* Resolve button in notifications */
.resolve-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #dcfce7;
    color: #059669;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resolve-btn:hover {
    background: #10b981;
    color: white;
    transform: scale(1.1);
}

.view-log-btn {
    padding: 0.25rem 0.75rem;
    border: none;
    background: #e2e8f0;
    color: #475569;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
}

.view-log-btn:hover {
    background: #6366f1;
    color: white;
}

/* ========================================
   RESERVATIONS PAGE - RESPONSIVE STYLES
   ======================================== */

/* Reservations header */
.reservations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.reservations-header h2 {
    margin: 0;
    font-size: 1.75rem;
    color: #1e293b;
}

/* Tabs styling */
.reservations-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #e2e8f0;
}

.reservations-tabs button {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

/* Stats cards grid */
.reservations-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.reservations-stats .stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Table responsive */
.reservations-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow-x: auto;
    border: 1px solid #e2e8f0;
}

/* Mobile styles for reservations */
@media (max-width: 768px) {
    /* Header responsive */
    #reservations .header,
    #reservations > div:first-child {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    #reservations h2 {
        font-size: 1.25rem !important;
    }
    
    /* Controls on separate row */
    #reservations > div:first-child > div:last-child {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    /* Stats banner - stack on mobile */
    #reservations > div[style*="linear-gradient"] {
        padding: 1rem !important;
    }
    
    #reservations > div[style*="linear-gradient"] > div {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    #reservations > div[style*="linear-gradient"] > div > div {
        padding: 0.75rem !important;
    }
    
    #reservations > div[style*="linear-gradient"] div[style*="font-size:2.5rem"],
    #reservations > div[style*="linear-gradient"] div[style*="font-size:2rem"],
    #reservations > div[style*="linear-gradient"] div[style*="font-size:1.5rem"] {
        font-size: 1.25rem !important;
    }
    
    /* Tabs - scrollable horizontal */
    #reservations > div[style*="border-bottom:2px solid"] {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    #reservations > div[style*="border-bottom:2px solid"]::-webkit-scrollbar {
        display: none;
    }
    
    #reservations > div[style*="border-bottom:2px solid"] button {
        padding: 0.75rem 1rem !important;
        font-size: 0.85rem !important;
        flex-shrink: 0;
    }
    
    /* Stats grid in tab content */
    #tabContent > div:first-child {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    #tabContent > div:first-child > div {
        padding: 1rem !important;
    }
    
    #tabContent > div:first-child div[style*="font-size:2rem"],
    #tabContent > div:first-child div[style*="font-size:1.5rem"] {
        font-size: 1.1rem !important;
    }
    
    /* Search and filter row */
    #tabContent > div[style*="display:flex"][style*="gap:1rem"] {
        flex-direction: column;
    }
    
    #tabContent input[type="text"] {
        min-width: 100% !important;
    }
    
    #tabContent select {
        width: 100%;
    }
    
    /* Table scrollable */
    #reservationsTable {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #reservationsTable table {
        min-width: 800px;
        font-size: 0.8rem;
    }
    
    #reservationsTable th,
    #reservationsTable td {
        padding: 0.5rem !important;
    }
    
    /* Load more button */
    #reservations button[onclick*="loadMore"] {
        width: 100%;
        padding: 0.875rem 1rem !important;
    }
}

@media (max-width: 480px) {
    #reservations > div[style*="linear-gradient"] > div {
        grid-template-columns: 1fr !important;
    }
    
    #tabContent > div:first-child {
        grid-template-columns: 1fr !important;
    }
    
    #reservations > div:first-child > div:last-child {
        flex-direction: column;
    }
    
    #reservations > div:first-child label {
        width: 100%;
    }
}
