* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    direction: rtl;
    unicode-bidi: embed;
}

* {
    unicode-bidi: inherit;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

.controls {
    padding: 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.filter-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: start;
}

.filter-section h2 {
    grid-column: 1 / -1;
    margin-bottom: 10px;
    color: #333;
    font-size: 1.5em;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
}

.filter-group input,
.filter-group select {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    font-family: inherit;
    direction: rtl;
    text-align: right;
}

.filter-group-products {
    grid-column: 1 / -1;
    max-width: 500px;
}

.product-select-wrapper {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.product-select-header {
    padding: 10px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.product-select-header input {
    flex: 1;
    min-width: 200px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9em;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-small:hover {
    background: #5568d3;
}

.product-checkbox-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
    direction: rtl;
}

.checkbox-label {
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 2px 0;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
    direction: rtl;
}

.checkbox-label:hover {
    background: #f8f9fa;
}

.checkbox-label input[type="checkbox"] {
    margin-left: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.checkbox-label span {
    flex: 1;
    user-select: none;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.stat-card:nth-child(2) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card:nth-child(3) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-card:nth-child(4) {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 1.1em;
    opacity: 0.9;
}

.charts-section {
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 30px;
}

.chart-container {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.chart-container h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5em;
}

.table-section,
.summary-section {
    padding: 30px;
}

.table-section h2,
.summary-section h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.8em;
}

.table-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.table-controls input,
.table-controls select {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    direction: rtl;
    text-align: right;
}

.table-controls input:focus,
.table-controls select:focus {
    outline: none;
    border-color: #667eea;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

th {
    padding: 15px;
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
    direction: rtl;
    unicode-bidi: embed;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    text-align: right;
    direction: rtl;
    unicode-bidi: embed;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr:nth-child(even) {
    background: #f8f9fa;
}

tbody tr:nth-child(even):hover {
    background: #e9ecef;
}

/* תגיות סוג מסמך */
.doc-type-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    white-space: nowrap;
}

.doc-type-badge.tax_invoice {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #1976d2;
}

.doc-type-badge.tax_invoice_receipt {
    background: #e8f5e9;
    color: #388e3c;
    border: 1px solid #388e3c;
}

.doc-type-badge.receipt {
    background: #fff3e0;
    color: #f57c00;
    border: 1px solid #f57c00;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .filter-section {
        grid-template-columns: 1fr;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.loading {
    text-align: center;
    padding: 50px;
    font-size: 1.5em;
    color: #667eea;
}

/* תיקון כיוון טקסט ב-options */
select option {
    direction: rtl;
    text-align: right;
    unicode-bidi: embed;
}

/* תיקון כיוון טקסט בתאים עם מספרים */
td[dir="ltr"] {
    direction: ltr;
    text-align: left;
    unicode-bidi: embed;
}

td[dir="rtl"] {
    direction: rtl;
    text-align: right;
    unicode-bidi: embed;
}

