* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Logowanie */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
}

.login-box {
    background-color: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

/* Header bar */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-bar h1 {
    margin: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
}

h2 {
    color: #34495e;
    margin-bottom: 20px;
}

/* Zakładki */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #3498db;
}

.tab-button {
    padding: 10px 20px;
    background-color: #ecf0f1;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    border-radius: 5px 5px 0 0;
}

.tab-button:hover {
    background-color: #bdc3c7;
}

.tab-button.active {
    background-color: #3498db;
    color: white;
}

.tab-content {
    display: none;
}

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

/* Sekcje */
.section {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

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

.section-header h2 {
    margin: 0;
}

/* Kontrolki sortowania */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-controls label {
    font-weight: bold;
    color: #555;
}

.sort-controls select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Podsumowanie */
.summary-box {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.summary-main-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.summary-item {
    text-align: center;
    padding: 10px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.summary-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.summary-item .number {
    font-size: 28px;
    font-weight: bold;
    color: #2c3e50;
}

.summary-item .label {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

/* Statystyki usług */
.summary-services {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

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

.services-header h4 {
    margin: 0;
    color: #34495e;
    font-size: 16px;
}

.stats-legend {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-item .stat-badge {
    font-size: 10px;
    padding: 2px 4px;
    min-width: auto;
}

.services-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.service-stat-item {
    background-color: #e9ecef;
    padding: 10px 15px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.service-stat-item:hover {
    background-color: #dee2e6;
}

.service-stat-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    flex: 1;
    margin-right: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-stat-counts {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stat-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
    cursor: default;
    transition: transform 0.2s ease;
}

.stat-badge:hover {
    transform: scale(1.1);
}

.stat-active {
    background-color: #d4edda;
    color: #155724;
}

.stat-inactive {
    background-color: #f8d7da;
    color: #721c24;
}

.stat-total {
    background-color: #cfe2ff;
    color: #084298;
}

/* Ostrzeżenie o wygasających usługach */
.expiring-soon {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.expiring-soon strong {
    color: #e74c3c;
}

/* Formularze */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input[type="file"] {
    padding: 6px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-group input[readonly] {
    background-color: #f0f0f0;
    cursor: not-allowed;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* Przyciski */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
    transition: all 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-info {
    background-color: #3498db;
    color: white;
}

.btn-info:hover {
    background-color: #2980b9;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}

/* Lista klientów i usług */
.client-card, .service-card {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

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

.client-header > div:last-child,
.service-header > div:last-child {
    display: flex;
    gap: 5px;
}

.client-name, .service-name {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

.client-info, .service-info {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.client-services {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.client-invoices h4,
.client-services h4 {
    margin-bottom: 15px;
    color: #34495e;
}

.service-item {
    background-color: #e9ecef;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.service-item > div:last-child {
    display: flex;
    gap: 5px;
}

.service-dates {
    font-size: 12px;
    color: #666;
}

/* Kolory statusów */
.text-danger {
    color: #e74c3c !important;
    font-weight: bold;
}

.text-warning {
    color: #f39c12 !important;
    font-weight: bold;
}

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

.status-expired {
    color: #e74c3c;
    font-weight: bold;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 90%;
    height: 85vh;
    margin: 2% auto;
    display: flex;
    flex-direction: column;
    padding: 0;
}

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

.modal-header h2 {
    margin: 0;
}

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

.pdf-preview-container {
    flex: 1;
    overflow: hidden;
    background-color: #525659;
    min-height: 400px;
}

#pdf-preview {
    width: 100%;
    height: 100%;
}

/* Faktury */
.client-invoices {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.invoice-item {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invoice-item-info {
    flex: 1;
}

.invoice-item-info .invoice-number {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.invoice-item-details {
    font-size: 12px;
    color: #666;
}

.invoice-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
}

.status-paid {
    background-color: #d4edda;
    color: #155724;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-overdue {
    background-color: #f8d7da;
    color: #721c24;
}

.invoice-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.invoice-summary-box {
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.invoice-summary-item {
    text-align: center;
}

.invoice-summary-item .amount {
    font-size: 20px;
    font-weight: bold;
    color: #2c3e50;
}

.invoice-summary-item .label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.modal-header .close {
    position: static;
    margin: 0;
}

.close:hover {
    color: #000;
}

/* Responsywność */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .client-header, .service-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .client-header > div:last-child,
    .service-header > div:last-child {
        width: 100%;
        justify-content: flex-start;
    }
    
    .btn {
        margin-bottom: 5px;
    }
    
    .service-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .service-item > div:last-child {
        margin-top: 10px;
    }
    
    .header-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .sort-controls {
        width: 100%;
    }
    
    .sort-controls select {
        width: 100%;
    }
    
    .summary-box {
        padding: 10px;
    }
    
    .summary-main-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .services-stats {
        grid-template-columns: 1fr;
    }
    
    .service-stat-item {
        padding: 8px 12px;
    }
    
    .stat-badge {
        padding: 2px 6px;
        font-size: 11px;
    }
    
    .services-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .stats-legend {
        font-size: 11px;
    }
    
    .invoice-summary-box {
        grid-template-columns: 1fr;
    }
    
    .invoice-item {
        flex-direction: column;
        gap: 10px;
    }
    
    .invoice-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .modal-large {
        max-width: 95%;
        height: 90vh;
        margin: 5% auto;
    }
    
    .modal-footer {
        flex-wrap: wrap;
    }
}