/* ===== Base Styles ===== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Rubik', 'Tahoma', sans-serif; 
}

html {
    /* overflow-x: hidden הוסר - שובר position:sticky על ידי יצירת scroll container */
}

body { 
    background: #f4f7fa; 
    min-height: 100vh; 
    direction: rtl; 
    line-height: 1.5; 
    color: #334155; 
    padding-bottom: 30px;
    /* overflow-x: hidden הוסר - שובר position:sticky על ידי יצירת scroll container */
}


/* ===== Header ===== */
.header { 
    position: relative; 
    min-height: 110px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    display: flex;
    align-items: center;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(123, 197, 214, 0.15);
}

/* Gradient top border - thicker and more vibrant */
.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #7BC5D6 0%, #5BA8C0 25%, #9B6DB5 75%, #8A5DAB 100%);
}

/* Subtle bottom accent */
.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(155, 109, 181, 0.2), transparent);
}

/* הלוגו - בצד ימין */
.header-logo { 
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.header-logo img { 
    height: 65px; 
    width: auto;
}

/* הכותרת - ממורכזת לכל הרוחב */
.header-center { 
    width: 100%;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    text-align: center; 
    padding: 22px;
}

.header h1 { 
    font-size: 28px; 
    font-weight: 600; 
    margin-bottom: 6px;
    background: linear-gradient(135deg, #5BA8C0 0%, #9B6DB5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p { 
    color: #64748b; 
    font-size: 14px; 
    font-weight: 400;
}

.header-logos { 
    display: flex; 
    gap: 12px; 
    align-items: center; 
}

.header-logos img { 
    height: 65px; 
    width: auto; 
}

/* ===== FAB Buttons - More vibrant ===== */
.fab-container {
    position: fixed;
    top: 18px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.fab {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    color: #64748b;
    cursor: pointer;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    box-shadow: 
        0 4px 15px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

.fab svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.fab:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 8px 25px rgba(123, 197, 214, 0.35),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

.fab:nth-child(1):hover {
    background: linear-gradient(145deg, #7BC5D6, #5BA8C0);
    color: white;
}

.fab:nth-child(2):hover {
    background: linear-gradient(145deg, #9B6DB5, #8A5DAB);
    color: white;
}

.fab:nth-child(3):hover {
    background: linear-gradient(145deg, #7BC5D6, #9B6DB5);
    color: white;
}

.fab.active {
    background: linear-gradient(145deg, #7BC5D6, #9B6DB5);
    color: white;
    box-shadow: 
        0 6px 20px rgba(155, 109, 181, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.fab.loading {
    pointer-events: none;
}

.fab.loading svg {
    animation: spinIcon 1s linear infinite;
}

@keyframes spinIcon {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* View Selector Popup */
.view-selector-popup {
    position: absolute;
    top: 56px;
    left: 0;
    background: white;
    border-radius: 16px;
    padding: 10px;
    box-shadow: 
        0 10px 40px rgba(0,0,0,0.15),
        0 0 0 1px rgba(155, 109, 181, 0.1);
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    z-index: 1001;
}

.view-selector-popup.active {
    display: flex;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.view-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #64748b;
    white-space: nowrap;
}

.view-option:hover {
    background: linear-gradient(135deg, rgba(123, 197, 214, 0.1), rgba(155, 109, 181, 0.1));
    color: #334155;
}

.view-option.active {
    background: linear-gradient(135deg, rgba(123, 197, 214, 0.2), rgba(155, 109, 181, 0.2));
    color: #8A5DAB;
    font-weight: 500;
}

.view-option-icon {
    font-size: 18px;
}

.view-option-text {
    font-weight: 500;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Year Selector ===== */
.year-selector { 
    padding: 24px 20px;
    display: flex;
    justify-content: center;
}

.year-buttons { 
    display: flex; 
    gap: 10px; 
    background: white;
    padding: 8px;
    border-radius: 16px;
    box-shadow: 
        0 4px 20px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

.year-button { 
    background: linear-gradient(145deg, #f8fafc, #f1f5f9);
    border: 2px solid transparent;
    border-radius: 12px; 
    padding: 14px 32px; 
    cursor: pointer; 
    transition: all 0.3s ease; 
    color: #64748b; 
    font-size: 14px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 2px;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.year-button:hover { 
    color: #475569;
    background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.year-button.active { 
    background: linear-gradient(135deg, #7BC5D6 0%, #9B6DB5 100%);
    border-color: transparent;
    color: white;
    box-shadow: 0 6px 20px rgba(155, 109, 181, 0.35);
    transform: translateY(-1px);
}

.year-hebrew { 
    font-size: 20px; 
    font-weight: 600; 
}

.year-english { 
    font-size: 11px; 
    opacity: 0.8; 
}

/* ===== Year Content ===== */
.year-content { 
    display: none;
    overflow: visible !important;
}

.year-content.active { 
    display: block;
    overflow: visible !important;
}

/* ===== Container ===== */
.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 20px 20px;
    position: relative;
    overflow-x: clip; /* מונע גלילה אופקית של הדף בלי לשבור sticky */
    overflow-y: visible;
}

/* ===== Loading & Error States ===== */
.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid #f1f5f9;
    border-top-color: #9B6DB5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.loading-text {
    color: #64748b;
    font-size: 16px;
}

.loading-progress {
    width: 200px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin: 16px auto 0;
    overflow: hidden;
}

.loading-progress-bar {
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, #7BC5D6, #9B6DB5);
    border-radius: 2px;
    animation: loading-progress 1.5s ease-in-out infinite;
}

@keyframes loading-progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 40px;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-container h3 {
    color: #dc2626;
    margin-bottom: 8px;
}

.error-container p {
    color: #64748b;
    margin-bottom: 20px;
}

.retry-button {
    background: linear-gradient(135deg, #7BC5D6 0%, #9B6DB5 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(155, 109, 181, 0.3);
}

/* ===== Summary Section ===== */
.summary-section {
    background: linear-gradient(145deg, #ffffff, #fafbfc);
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: 
        0 4px 25px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.8);
    position: relative;
    overflow: hidden;
}

.summary-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #7BC5D6, #9B6DB5, #ef4444);
}

.summary-title {
    text-align: center;
    margin-bottom: 20px;
}

.summary-title h2 {
    color: #1e293b;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.summary-title p {
    color: #64748b;
    font-size: 14px;
    margin: 4px 0 0 0;
}

/* ===== Summary Cards ===== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.summary-card {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    border-right: 4px solid;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

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

.summary-card.income {
    border-right-color: #10b981;
}

.summary-card.income:hover {
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.2);
}

.summary-card.expense {
    border-right-color: #ef4444;
}

.summary-card.expense:hover {
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.2);
}

.summary-card.balance {
    border-right-color: #7BC5D6;
}

.summary-card.balance:hover {
    box-shadow: 0 8px 25px rgba(123, 197, 214, 0.25);
}

.summary-card .card-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 8px;
}

.summary-card .card-planned {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.summary-card .card-actual {
    font-size: 20px;
    font-weight: 700;
    direction: ltr;
}

.summary-card.income .card-actual {
    color: #10b981;
}

.summary-card.expense .card-actual {
    color: #ef4444;
}

.summary-card.balance .card-actual.positive {
    color: #0ea5e9;
}

.summary-card.balance .card-actual.negative {
    color: #ef4444;
}

/* ===== Summary Tables - Two Column Layout ===== */
.summary-tables-container {
    display: flex;
    gap: 24px;
    margin-top: 24px;
    align-items: flex-start;
}

.summary-half {
    flex: 1;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.half-title {
    padding: 14px 20px;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.income-title {
    background: #d1fae5;
    color: #065f46;
    border-right: 4px solid #10b981;
}

.expense-title {
    background: #fee2e2;
    color: #991b1b;
    border-right: 4px solid #ef4444;
}

.half-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.half-table th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: center;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
}

.half-table th:first-child {
    text-align: right;
}

.half-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
}

.half-table td.item-name {
    text-align: right;
    font-weight: 500;
}

.half-table td.amount {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-family: 'Rubik', monospace;
    text-align: right;
    padding-left: 20px;
}

.half-table .positive {
    color: #10b981;
}

.half-table .negative {
    color: #ef4444;
}

.half-total {
    font-weight: 700;
}

.income-total-row {
    background: #ecfdf5;
}

.expense-total-row {
    background: #fef2f2;
}

.income-total-row td,
.expense-total-row td {
    text-align: center;
}

.income-total-row td:first-child,
.expense-total-row td:first-child {
    text-align: right;
}

/* שורות ריקות להשוואת גובה */
.empty-row {
    visibility: hidden;
}

.empty-row td {
    padding: 10px 14px !important;
    border-bottom: 1px solid transparent !important;
}

/* שורת יתרה תחתונה */
.summary-balance-row {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 24px;
    padding: 20px;
    background: #f1f5f9;
    border-radius: 12px;
}

.balance-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.balance-item.main-balance {
    padding: 0 30px;
    border-left: 2px solid #cbd5e1;
    border-right: 2px solid #cbd5e1;
}

.balance-label {
    font-size: 13px;
    color: #64748b;
}

.balance-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.balance-value.positive {
    color: #10b981;
}

.balance-value.negative {
    color: #ef4444;
}

/* Responsive */
@media (max-width: 900px) {
    .summary-tables-container {
        flex-direction: column;
    }
    
    .summary-balance-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .balance-item.main-balance {
        border: none;
        padding: 16px 0;
        border-top: 2px solid #cbd5e1;
        border-bottom: 2px solid #cbd5e1;
    }
}

/* ===== Old Summary Table (keep for compatibility) ===== */
.summary-table-wrapper {
    overflow-x: auto;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.summary-table th {
    background: #f8fafc;
    color: #374151;
    font-weight: 600;
    padding: 12px 16px;
    text-align: center;
    border-bottom: 2px solid #e2e8f0;
}

.summary-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
}

.summary-table tbody tr:hover {
    background: #f8fafc;
}

.summary-table .category-name {
    text-align: right;
    font-weight: 600;
    color: #1e293b;
}

.summary-table .category-icon {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
}

.summary-table .amount {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-family: 'Rubik', monospace;
    text-align: right;
    min-width: 100px;
    padding-left: 20px;
}

.summary-table .amount.positive {
    color: #10b981;
    font-weight: 600;
}

.summary-table .amount.negative {
    color: #ef4444;
    font-weight: 600;
}

.summary-table .total-row {
    background: #f1f5f9;
    font-weight: 700;
    border-top: 2px solid #e2e8f0;
}

.summary-table .total-row td {
    padding: 14px 16px;
}

/* שורות כותרת סקציה */
.summary-table .section-header-row td {
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 700;
    text-align: right;
}

.summary-table .income-header td {
    color: #065f46;
    background: #d1fae5;
    border-right: 4px solid #10b981;
}

.summary-table .expense-header td {
    color: #991b1b;
    background: #fee2e2;
    border-right: 4px solid #ef4444;
}

/* שורות משנה */
.summary-table .sub-row .sub-category {
    padding-right: 30px;
    font-weight: 400;
}

/* שורות סיכום סקציה */
.summary-table .section-total-row {
    font-weight: 600;
}

.summary-table .section-total-row td {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
}

.summary-table .income-total td {
    background: #ecfdf5;
}

.summary-table .expense-total td {
    background: #fef2f2;
}

/* ביטול hover על שורות כותרת וסיכום */
.summary-table .section-header-row:hover td,
.summary-table .section-total-row:hover td,
.summary-table .total-row:hover td {
    background: inherit;
}

.summary-table .income-header:hover td {
    background: #d1fae5;
}

.summary-table .expense-header:hover td {
    background: #fee2e2;
}

.summary-table .income-total:hover td {
    background: #ecfdf5;
}

.summary-table .expense-total:hover td {
    background: #fef2f2;
}

/* ===== Category Section ===== */
.category-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    overflow: visible;
    border: 1px solid #e2e8f0;
    position: relative;
}

/* קטגוריות פתוחות כברירת מחדל */
.category-section .category-content {
    display: block;
}

.category-section.collapsed .category-content {
    display: none;
}

.category-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 12px 12px 0 0; /* פינות מעוגלות למעלה */
}

.category-header:hover {
    background: #f8fafc;
}

.category-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-icon-large {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.category-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.category-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.category-totals {
    display: grid;
    grid-template-columns: repeat(3, 140px);
    gap: 8px;
}

.category-total-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.category-total-label {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 2px;
}

.category-total-value {
    font-size: 15px;
    font-weight: 600;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-family: 'Rubik', monospace;
    text-align: right;
}

.category-total-value.positive {
    color: #10b981;
}

.category-total-value.negative {
    color: #ef4444;
}

.expand-arrow {
    font-size: 14px;
    color: #94a3b8;
    transition: transform 0.3s ease;
}

.category-section.collapsed .expand-arrow {
    transform: rotate(-90deg);
}

/* ===== Category Content ===== */
.category-content {
    border-top: 1px solid #e2e8f0;
    overflow: visible !important;
}

.category-section.collapsed .expand-arrow {
    transform: rotate(-90deg);
}

.items-table-wrapper {
    overflow: visible;
    padding: 0;
    margin: 0;
}

.items-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    font-size: 13px;
}

.items-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.items-table tbody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

.items-table tbody tr:hover {
    background: #f8fafc;
}

.items-table .item-name {
    text-align: right;
    font-weight: 500;
    color: #1e293b;
    font-size: 14px;
    width: 160px;
    min-width: 120px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.items-table .item-amount {
    text-align: right;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-family: 'Rubik', monospace;
    width: 120px;
    min-width: 100px;
    max-width: 130px;
    padding-left: 12px;
    padding-right: 12px;
    white-space: nowrap;
}

.items-table .item-percentage {
    text-align: right;
    width: 200px;
    min-width: 160px;
}

/* יישור כותרות מעל הסכומים */
.items-table th:nth-child(2),
.items-table th:nth-child(3),
.items-table th:nth-child(4) {
    text-align: right;
    padding-left: 12px;
    padding-right: 12px;
}

.items-table .item-amount.positive {
    color: #10b981;
    font-weight: 600;
}

.items-table .item-amount.negative {
    color: #ef4444;
    font-weight: 600;
}

.items-table .item-percentage {
    text-align: center;
}

.percentage-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.percentage-badge.good {
    background: #dcfce7;
    color: #16a34a;
}

.percentage-badge.warning {
    background: #fef3c7;
    color: #d97706;
}

.percentage-badge.danger {
    background: #fee2e2;
    color: #dc2626;
}

.items-table .summary-row {
    background: #f1f5f9;
    font-weight: 600;
}

.items-table .summary-row td {
    padding: 12px;
    border-top: 2px solid #e2e8f0;
}

.items-table .summary-row td.item-amount {
    padding-left: 12px;
    padding-right: 12px;
}

/* ===== Item Details ===== */
.details-row {
    display: none;
}

.details-row.active {
    display: table-row;
}

.details-row > td {
    padding: 0 !important;
    border: none !important;
}

.item-details {
    background: #fafbfc;
    padding: 16px 24px;
    border-top: 1px dashed #e2e8f0;
}

.details-wrapper {
    max-width: 750px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

.details-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}


.filter-input {
    flex: 1;
    max-width: 280px;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Rubik', sans-serif;
    transition: border-color 0.2s;
}

.filter-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-input::placeholder {
    color: #94a3b8;
}

.details-count {
    font-size: 12px;
    color: #64748b;
    background: #e2e8f0;
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.details-table-container {
    max-height: 400px;
    overflow-y: auto;
}

.details-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.details-table th {
    background: #f1f5f9;
    padding: 12px 14px;
    text-align: center;
    font-weight: 600;
    color: #475569;
    position: sticky;
    top: 0;
}

.details-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
}

.details-table tbody tr:hover {
    background: #f8fafc;
}

.details-table .detail-date {
    text-align: center;
    color: #64748b;
    font-size: 12px;
    width: 85px;
}

.details-table .detail-description {
    text-align: right;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.details-table .detail-amount {
    text-align: right;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-family: 'Rubik', monospace;
    width: 100px;
    padding-left: 15px;
}

/* Monthly amount in details */
.monthly-amount {
    font-size: 11px;
    color: #64748b;
    margin-right: 6px;
}

.monthly-amount.negative {
    color: #ef4444;
}

/* ===== Unmatched Items ===== */
.unmatched-item {
    background: #fffbeb !important;
    border-right: 3px solid #f59e0b;
}

.unmatched-item .item-name::before {
    content: '⚠️ ';
    font-size: 12px;
}

.container.hide-unmatched .unmatched-item {
    display: none;
}

/* ===== Unmatched Floating Button ===== */
/* ===== Unmatched Section ===== */
/* ===== Actions Section (Unmatched + Export) ===== */
.actions-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 30px 20px;
    margin-top: 20px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    font-family: 'Rubik', sans-serif;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 109, 181, 0.2);
    border-color: #9B6DB5;
    color: #8A5DAB;
}

.action-btn:active {
    transform: translateY(0);
}

/* Active state for unmatched button */
.action-btn.active {
    background: linear-gradient(135deg, rgba(123, 197, 214, 0.15), rgba(155, 109, 181, 0.15));
    border-color: #9B6DB5;
    color: #8A5DAB;
}

.action-btn svg {
    flex-shrink: 0;
}

/* Hide unmatched button in departments view */
.container.departments-view .action-btn:first-child {
    display: none;
}

@media (max-width: 768px) {
    .actions-section {
        flex-direction: column;
        gap: 12px;
        padding: 20px;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== Last Updated ===== */
.last-updated {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: #64748b;
    font-size: 12px;
    margin-bottom: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.last-updated .update-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.last-updated .update-item svg {
    width: 14px;
    height: 14px;
    stroke: #9B6DB5;
}

.last-updated .update-separator {
    color: #cbd5e1;
    margin: 0 4px;
}

/* ===== Edit Icon ===== */
.edit-icon {
    opacity: 0;
    margin-right: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.items-table tbody tr:hover .edit-icon {
    opacity: 0.6;
}

.edit-icon:hover {
    opacity: 1 !important;
    transform: scale(1.2);
}

/* ===== Edit Popup ===== */
.edit-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.edit-popup-overlay.active {
    display: flex;
}

.edit-popup {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    animation: popupSlideIn 0.3s ease;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.edit-popup-header {
    background: linear-gradient(135deg, #2196F3 0%, #1976d2 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-popup-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-popup-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s ease;
}

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

.edit-popup-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.edit-field {
    margin-bottom: 20px;
}

.edit-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.edit-field input[type="text"],
.edit-field input[type="number"],
.edit-field select,
.edit-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Rubik', sans-serif;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    direction: rtl;
}

.edit-field input:focus,
.edit-field select:focus,
.edit-field textarea:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.edit-field textarea {
    min-height: 80px;
    resize: vertical;
}

.edit-popup-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-start;
}

.save-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Rubik', sans-serif;
}

.save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.cancel-btn {
    background: #f1f5f9;
    color: #64748b;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Rubik', sans-serif;
}

.cancel-btn:hover {
    background: #e2e8f0;
}

.edit-popup-status {
    padding: 0 24px 16px;
    text-align: center;
    min-height: 24px;
}

.edit-popup-status .saving { color: #2196F3; }
.edit-popup-status .success { color: #10b981; font-weight: 600; }
.edit-popup-status .error { color: #ef4444; }

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .header {
        min-height: 90px;
    }
    
    .header-logo {
        right: 16px;
    }
    
    .header-logo img {
        height: 50px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .header p {
        font-size: 12px;
    }
    
    .fab-container {
        top: 14px;
        left: 14px;
        gap: 8px;
    }
    
    .fab {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    
    .view-selector-popup {
        top: 48px;
    }
    
    .container {
        padding: 12px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }
    
    .category-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .category-header-right {
        flex-direction: column;
        gap: 8px;
    }
    
    .category-totals {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .items-table th,
    .items-table td {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    .period-selector-bar {
        padding: 10px 12px;
    }
    
    .period-chip {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .refresh-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .settings-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
        right: 62px;
    }
    
    .edit-popup {
        width: 95%;
        max-height: 85vh;
    }
    
    .edit-popup-footer {
        flex-direction: column;
    }
    
    .save-btn, .cancel-btn {
        width: 100%;
    }
}

/* ===== Print Styles ===== */
@media print {
    .fab-container,
    .actions-section,
    .edit-popup-overlay {
        display: none !important;
    }
    
    .category-section {
        break-inside: avoid;
    }
}

/* ===== Floating Toolbar ===== */
.floating-toolbar {
    position: static;
    background: white;
    border-radius: 50px;
    padding: 10px 28px;
    box-shadow: 
        0 4px 25px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0 auto 24px auto;
    width: fit-content;
    transition: all 0.3s ease;
}

/* Floating state - when triggered by FAB button */
.floating-toolbar.floating {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.view-icons {
    display: flex;
    gap: 6px;
}

.view-icon-btn {
    width: 46px;
    height: 46px;
    border: none;
    background: linear-gradient(145deg, #f8fafc, #f1f5f9);
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    color: #64748b;
}

.view-icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.view-icon-btn.active {
    background: linear-gradient(135deg, #7BC5D6, #9B6DB5);
    color: white;
    box-shadow: 0 4px 15px rgba(155, 109, 181, 0.35);
}

.view-icon-btn:hover:not(.active) {
    background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.view-icon-btn:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 54px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.toolbar-separator {
    width: 2px;
    height: 32px;
    background: linear-gradient(180deg, transparent, #e2e8f0, transparent);
    border-radius: 1px;
}

.select-all-btn {
    padding: 10px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    background: white;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.select-all-btn:hover {
    background: linear-gradient(135deg, rgba(123, 197, 214, 0.1), rgba(155, 109, 181, 0.1));
    border-color: #9B6DB5;
    color: #8A5DAB;
    transform: translateY(-1px);
}
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    color: #64748b;
    transition: all 0.2s;
    white-space: nowrap;
}

.select-all-btn:hover {
    background: #f1f5f9;
    border-color: #0ea5e9;
    color: #0ea5e9;
}

.select-all-btn.all-selected {
    background: #dcfce7;
    border-color: #22c55e;
    color: #16a34a;
}

.month-dots {
    display: flex;
    gap: 6px;
}

.month-dot {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.25s ease;
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    font-family: inherit;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.month-dot.selected {
    background: linear-gradient(135deg, #7BC5D6, #9B6DB5);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(155, 109, 181, 0.3);
}

.month-dot:hover:not(.selected) {
    border-color: #9B6DB5;
    color: #8A5DAB;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.quarter-dots {
    display: flex;
    gap: 8px;
}

.quarter-dot {
    padding: 10px 20px;
    border-radius: 25px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    transition: all 0.25s ease;
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    font-family: inherit;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.quarter-dot.selected {
    background: linear-gradient(135deg, #7BC5D6, #9B6DB5);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(155, 109, 181, 0.3);
}

.quarter-dot:hover:not(.selected) {
    border-color: #9B6DB5;
    color: #8A5DAB;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* ===== Monthly/Quarterly Tables ===== */
.period-table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    margin-top: 0;
    max-width: 100%;
}

/* Sticky Header Container - נוצר ע"י JavaScript */
/* top = גובה סטריפ התקופה */
.sticky-header-container {
    position: sticky;
    top: 54px;
    z-index: 100;
    background: white;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0;
    padding: 0;
}

.sticky-header-container::-webkit-scrollbar {
    display: none;
}

.sticky-header-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* עמודות קבועות בכותרת המשוכפלת - z-index גבוה יותר מכותרות החודשים */
.sticky-header-container thead th:first-child {
    position: sticky !important;
    right: 0 !important;
    z-index: 30 !important;
    background: #f8fafc !important;
}

.sticky-header-container thead tr:nth-child(2) th:first-child {
    z-index: 29 !important;
}

.sticky-header-container .summary-header {
    position: sticky !important;
    z-index: 28 !important;
}

.sticky-header-container .summary-col {
    position: sticky !important;
    z-index: 27 !important;
}

.sticky-header-container .summary-col.budget-summary {
    right: 160px !important;
    background: #dbeafe !important;
}

.sticky-header-container .summary-col.actual-summary {
    right: 240px !important;
    background: #dbeafe !important;
}

.sticky-header-container .summary-col.balance-summary {
    right: 320px !important;
    background: #dbeafe !important;
}

.sticky-header-container .periodic-budget-col {
    position: sticky !important;
    right: 400px !important;
    z-index: 26 !important;
    background: #fef9c3 !important;
}

/* כותרות החודשים - z-index נמוך יותר */
.sticky-header-container .period-header {
    z-index: 5 !important;
}

.sticky-header-container .actual-col,
.sticky-header-container .balance-col {
    z-index: 5 !important;
}

/* טבלה רגילה (חודשית) */
.period-table {
    width: max-content;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

/* טבלה רבעונית */
.period-table.quarterly-view {
    width: max-content;
    min-width: auto;
    table-layout: auto;
}

/* ביטול table-layout: fixed רק לעמודות הקבועות */
.period-table.quarterly-view colgroup col.fixed-col {
    width: auto;
}

.period-table.quarterly-view .period-header {
    width: 220px !important;
    min-width: 220px !important;
}

.period-table.quarterly-view .actual-col:not(.summary-col),
.period-table.quarterly-view .balance-col:not(.summary-col) {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
}

/* עמודות קבועות בתצוגה רבעונית - שומרות על רוחב קבוע */
.period-table.quarterly-view thead th:first-child,
.period-table.quarterly-view tbody td:first-child {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
}

.period-table.quarterly-view .summary-col.budget-summary {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    right: 160px !important;
}

.period-table.quarterly-view .summary-col.actual-summary {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    right: 240px !important;
}

.period-table.quarterly-view .summary-col.balance-summary {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    right: 320px !important;
}

.period-table.quarterly-view .periodic-budget-col {
    width: 85px !important;
    min-width: 85px !important;
    max-width: 85px !important;
    right: 400px !important;
}

/* ===== טבלה חודשית ===== */
.period-table.monthly-view {
    width: max-content;
    min-width: auto;
}

/* עמודות קבועות בתצוגה חודשית */
.period-table.monthly-view thead th:first-child,
.period-table.monthly-view tbody td:first-child {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
}

/* סיכום תקופתי בחודשי */
.period-table.monthly-view .summary-col.budget-summary {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    right: 160px !important;
}

.period-table.monthly-view .summary-col.actual-summary {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    right: 240px !important;
}

.period-table.monthly-view .summary-col.balance-summary {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    right: 320px !important;
}

.period-table.monthly-view .periodic-budget-col {
    width: 85px !important;
    min-width: 85px !important;
    max-width: 85px !important;
    right: 400px !important;
}

/* כותרת סה"כ שנתי - קיבוע */
.period-table.monthly-view .summary-header {
    position: sticky;
    right: 160px;
    z-index: 10;
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%) !important;
}

.period-table.monthly-view thead .summary-col {
    position: sticky;
    z-index: 10;
    background: #dbeafe !important;
}

/* חודשים - רוחב אחיד */
.period-table.monthly-view .period-header {
    width: 220px !important;
    min-width: 220px !important;
}

.period-table.monthly-view .actual-col:not(.summary-col),
.period-table.monthly-view .balance-col:not(.summary-col) {
    width: 110px !important;
    min-width: 110px !important;
}

/* תיקון רקע לכותרות sticky בשורה השנייה */
.period-table.monthly-view thead tr:nth-child(2) th.summary-col {
    background: #dbeafe !important;
}

.period-table.monthly-view thead tr:nth-child(2) th.summary-col.budget-summary {
    background: #dbeafe !important;
}

.period-table.monthly-view thead tr:nth-child(2) th.summary-col.actual-summary {
    background: #dbeafe !important;
}

.period-table.monthly-view thead tr:nth-child(2) th.summary-col.balance-summary {
    background: #dbeafe !important;
}

.period-table.monthly-view thead tr:nth-child(2) .periodic-budget-col {
    background: #fef9c3 !important;
}

/* תיקון רקע לכותרת סה"כ שנתי בשורה הראשונה */
.period-table.monthly-view thead tr:first-child .summary-header {
    background: #dbeafe !important;
    position: sticky;
    right: 160px;
    z-index: 11;
}

/* תיקון רקע לתקציב חודשי בשורה הראשונה */
.period-table.monthly-view thead tr:first-child .periodic-budget-col {
    background: #fef9c3 !important;
    position: sticky;
    z-index: 11;
}

/* כיסוי הרווחים - שימוש ב-box-shadow במקום border */
.period-table.monthly-view {
    border-collapse: separate;
    border-spacing: 0;
}

.period-table.monthly-view thead th {
    border-bottom: none;
    box-shadow: inset 0 -2px 0 #e2e8f0;
}

/* רקע מלא לשורות הכותרת הקבועות */
.period-table.monthly-view thead tr:first-child th:first-child {
    background: #f8fafc !important;
}

.period-table.monthly-view thead tr:nth-child(2) th:first-child {
    background: #f8fafc !important;
}

.period-table thead th {
    background: #f8fafc;
    padding: 10px 8px;
    font-weight: 600;
    font-size: 11px;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    text-align: center;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 15;
    background-clip: padding-box;
}

/* שורה שנייה של הכותרת */
.period-table thead tr:nth-child(2) th {
    top: 36px;
    z-index: 14;
}

/* שם סעיף - sticky גם בימין וגם למעלה */
.period-table thead th:first-child {
    text-align: right;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    position: sticky;
    right: 0;
    top: 0;
    z-index: 25;
    background: #f8fafc;
}

.period-table thead tr:nth-child(2) th:first-child {
    top: 36px;
    z-index: 24;
}

.period-table tbody td:first-child {
    text-align: right;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    position: sticky;
    right: 0;
    z-index: 5;
    background: white;
}

/* ===== Summary Header (סה״כ תקופתי) ===== */
.period-table .summary-header {
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%) !important;
    color: #1e40af;
    font-weight: 700;
    font-size: 12px;
}

/* Summary columns - מסגרת סיכום תקופתי */
.period-table .summary-col {
    position: sticky;
    z-index: 8;
    padding: 8px 4px !important;
}

.period-table .summary-col.budget-summary {
    right: 160px;
    background: #eff6ff !important;
    width: 80px;
    min-width: 80px;
    max-width: 80px;
}

.period-table .summary-col.actual-summary {
    right: 240px;
    background: #eff6ff !important;
    width: 80px;
    min-width: 80px;
    max-width: 80px;
}

.period-table .summary-col.balance-summary {
    right: 320px;
    background: #eff6ff !important;
    width: 80px;
    min-width: 80px;
    max-width: 80px;
}

.period-table thead .summary-col {
    background: #dbeafe !important;
    z-index: 20;
}

.period-table thead .summary-col.budget-summary,
.period-table thead .summary-col.actual-summary,
.period-table thead .summary-col.balance-summary {
    background: #dbeafe !important;
}

/* ===== Periodic Budget Column (תקציב חודשי/רבעוני) ===== */
.period-table .periodic-budget-col {
    position: sticky;
    z-index: 7;
    background: #fefce8 !important;
    border-right: 2px solid #cbd5e1;
    border-left: 2px solid #cbd5e1;
    width: 85px;
    min-width: 85px;
    max-width: 85px;
}

/* חישוב מיקום דינמי - כשיש ביצוע ויתרה */
.period-table .periodic-budget-col {
    right: 400px;
}

.period-table thead .periodic-budget-col {
    z-index: 20;
}

.period-table thead .periodic-budget-col {
    background: #fef9c3 !important;
    z-index: 10;
}

/* Period header - bigger font for months/quarters */
.period-table .period-header {
    background: #e0f2fe !important;
    color: #0369a1;
    font-weight: 700;
    font-size: 15px;
    text-align: center;
}

/* רוחב אחיד לעמודות חודשים/רבעונים */
.period-table .actual-col:not(.summary-col),
.period-table .balance-col:not(.summary-col) {
    width: 75px;
    min-width: 75px;
    max-width: 75px;
}

/* Month separator */
.period-table .month-sep {
    border-left: 2px solid #cbd5e1;
}

.period-table tbody td {
    padding: 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
}

.period-table tbody td:first-child {
    direction: rtl;
    text-align: right;
}

/* יישור מספרים בכל עמודות הסכומים - לימין */
.period-table .summary-col,
.period-table .periodic-budget-col,
.period-table .actual-col,
.period-table .balance-col {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    text-align: right;
    padding-right: 8px !important;
}

/* כותרות - יישור למרכז */
.period-table thead th.summary-col,
.period-table thead th.periodic-budget-col,
.period-table thead th.actual-col,
.period-table thead th.balance-col,
.period-table thead th.period-header {
    text-align: center !important;
    padding-right: 8px !important;
    padding-left: 8px !important;
}

.period-table tbody tr:hover td {
    background: #f8fafc;
}

.period-table tbody tr:hover td:first-child {
    background: #f8fafc;
}

.period-table tbody tr:hover .summary-col {
    background: #dbeafe !important;
}

.period-table tbody tr:hover .periodic-budget-col {
    background: #fef9c3 !important;
}

/* Category row in period table */
.period-table .period-category-row td {
    background: #f1f5f9 !important;
    font-weight: 700;
    padding: 12px 8px;
}

.period-table .period-category-row td:first-child {
    background: #f1f5f9 !important;
    position: sticky;
    right: 0;
    z-index: 5;
}

.period-table .period-category-row .summary-col {
    background: #dbeafe !important;
}

.period-table .period-category-row .periodic-budget-col {
    background: #fef3c7 !important;
}

/* Item name in period table */
.period-table .period-item-name {
    padding-right: 20px !important;
    cursor: pointer;
}

.period-table .period-item-name:hover {
    color: #0ea5e9;
}

/* Summary row */
.period-table .period-summary-row td {
    font-weight: 600;
    background: #f8fafc !important;
    border-top: 2px solid #e2e8f0;
}

.period-table .period-summary-row td:first-child {
    background: #f8fafc !important;
    position: sticky;
    right: 0;
    z-index: 5;
}

.period-table .period-summary-row .summary-col {
    background: #dbeafe !important;
}

.period-table .period-summary-row .periodic-budget-col {
    background: #fef9c3 !important;
}

.period-table .period-summary-row.income-summary td {
    background: #ecfdf5 !important;
}

.period-table .period-summary-row.income-summary td:first-child {
    background: #ecfdf5 !important;
}

.period-table .period-summary-row.income-summary .summary-col {
    background: #d1fae5 !important;
}

.period-table .period-summary-row.expense-summary td {
    background: #fef2f2 !important;
}

.period-table .period-summary-row.expense-summary td:first-child {
    background: #fef2f2 !important;
}

.period-table .period-summary-row.expense-summary .summary-col {
    background: #fee2e2 !important;
}

/* Hide columns based on settings */
.hide-actual .actual-col {
    display: none;
}

.hide-balance .balance-col {
    display: none;
}

/* Period table wrapper scrollbar styling */
.period-table-wrapper {
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
}

.period-table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.period-table-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 5px;
}

.period-table-wrapper::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}

.period-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* View mode responsive */
@media (max-width: 768px) {
    .view-controls-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .view-toggle-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .month-chip {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .period-table {
        font-size: 10px;
    }
    
    .period-table thead th,
    .period-table tbody td {
        padding: 6px 4px;
    }
}

/* No selection message */
.no-selection-message {
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: 16px;
    background: white;
    border-radius: 12px;
    margin: 20px 0;
}

/* Period table item name clickable */
.period-table .period-item-name {
    cursor: pointer;
    transition: color 0.2s;
}

.period-table .period-item-name:hover {
    color: #0ea5e9;
}

/* Edit icon spacing in period view */
.period-table .edit-icon {
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.period-table .edit-icon:hover {
    opacity: 1;
}

/* ===== Period Details Inline ===== */
.period-details-row {
    display: none;
}

.period-details-row.active {
    display: table-row;
}

.period-details-row > td {
    padding: 0 !important;
    background: #f8fafc;
    vertical-align: top;
}

.period-details-row .details-cell {
    padding: 8px !important;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    vertical-align: top;
}

.period-details-row .details-cell-name {
    background: #f1f5f9 !important;
    border-bottom: 2px solid #e2e8f0;
    padding: 8px !important;
    vertical-align: top;
    position: sticky;
    right: 0;
    z-index: 5;
}

.period-details-row .details-cell-budget {
    background: #fef9c3 !important;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    right: 160px;
    z-index: 4;
}

.period-details-row .total-col {
    background: #f0fdf4 !important;
    position: sticky;
    z-index: 3;
}

/* עמודות סיכום בשורת פירוט */
.period-details-row .summary-col {
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    z-index: 4;
    height: 100%;
    min-height: inherit;
}

.period-details-row .summary-col.budget-summary {
    background: #dbeafe !important;
    right: 160px;
}

.period-details-row .summary-col.actual-summary {
    background: #dbeafe !important;
    right: 240px;
}

.period-details-row .summary-col.balance-summary {
    background: #dbeafe !important;
    right: 320px;
}

.period-details-row .periodic-budget-col {
    background: #fef9c3 !important;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    right: 400px;
    z-index: 4;
    height: 100%;
    min-height: inherit;
}

/* חיפוש בכל תא */

/* === שורת סיכום תחת כרטסת (חודשי/רבעוני) === */
.acc-group-summary-row td {
    padding: 2px 6px;
    line-height: 1.5;
    background: #f0f7ff;
    font-size: 10.5px;
}

/* טבלה פנימית של כרטסת — יוצאת מה-fixed ומאפשרת גלילה אופקית */
.month-cell-content table.acc-inner-table {
    table-layout: auto !important;
    width: auto !important;
    min-width: 100%;
}

/* טבלת summary — auto כדי שעמודת הסכום תתרחב */
.month-cell-content table.acc-group-summary-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.acc-sum-label {
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-sum-val {
    color: #1e293b;
    font-weight: 700;
    text-align: left;
    direction: ltr;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-sum-val.negative {
    color: #dc2626;
}

.acc-sum-val.positive {
    color: #16a34a;
}

.acc-group-summary-divider td {
    height: 3px;
    background: #e2e8f0;
    padding: 0 !important;
}

.month-cell-content {
    display: flex;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
    padding-left: 4px;
}

.month-cell-content table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    box-sizing: border-box;
}

/* acc-inner-table — fixed כמו כל הטבלאות */
.month-cell-content table.acc-inner-table {
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100% !important;
}

.month-cell-content table.month-transactions td.trans-desc {
    width: 65% !important;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
}

.month-cell-content table.month-transactions td.trans-amount {
    width: 35% !important;
    text-align: left !important;
    direction: ltr !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* בתוך breakdown — הסכום בכותרת הקבוצה לא ייחתך */
.month-cell-content table.acc-inner-table td.trans-amount,
.month-cell-content table.acc-inner-table td.account-group-cell {
    white-space: nowrap !important;
    overflow: visible !important;
    width: auto !important;
    min-width: 0 !important;
}
.month-cell-content table.acc-inner-table td.trans-desc {
    width: auto !important;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
}

.month-cell-content .account-group-header td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    padding: 3px 6px !important;
}

/* Tooltip על כותרת קבוצה */
.account-group-header[title] {
    cursor: help;
}

.month-search-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    margin-bottom: 6px;
    text-align: right;
}

.month-search-input:focus {
    outline: none;
    border-color: #0ea5e9;
}

/* רשימת תנועות */
.month-transactions {
    max-height: 250px;
    overflow-y: auto;
    font-size: 11px;
    width: 100%;
    border-collapse: collapse;
}

.transaction-row {
    border-bottom: 1px solid #e2e8f0;
    cursor: default;
    direction: rtl;
}

.transaction-row td {
    padding: 6px 8px;
    vertical-align: middle;
    font-size: 11px;
}

.transaction-row td.trans-desc {
    width: 70%;
}

.transaction-row td.trans-amount {
    width: 30%;
    text-align: left;
}

.transaction-row:last-child {
    border-bottom: none;
}

.transaction-row:hover {
    background: #e0f2fe;
}

.trans-desc {
    text-align: right;
    color: #334155;
    font-size: 11px;
    line-height: 1.4;
    direction: rtl;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trans-amount {
    font-weight: 400;
    font-size: 11px;
    white-space: nowrap;
    color: #475569;
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.trans-amount.negative {
    color: #ef4444;
}

.no-trans {
    text-align: center;
    color: #94a3b8;
    padding: 15px;
    font-size: 12px;
}

/* גלילה עליונה */
.period-scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 16px;
    margin-bottom: 0;
    scrollbar-width: thin;
}

.period-scroll-top::-webkit-scrollbar {
    height: 10px;
}

.period-scroll-top::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 5px;
}

.period-scroll-top::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}

.period-scroll-top::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.period-scroll-top-inner {
    height: 1px;
}

@media (max-width: 768px) {
    .month-transactions {
        font-size: 10px;
        max-height: 200px;
    }
    
    .transaction-row {
        padding: 5px 8px;
        gap: 10px;
    }
    
    .trans-desc {
        font-size: 10px;
    }
    
    .trans-amount {
        font-size: 10px;
        width: 70px;
        min-width: 70px;
        max-width: 70px;
    }
    
    .details-search-input {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .period-table .period-header {
        font-size: 13px;
    }
    
    .period-table thead th:first-child,
    .period-table tbody td:first-child {
        width: 130px;
        min-width: 130px;
        max-width: 130px;
    }
    
    .period-table .budget-col {
        right: 130px;
        width: 70px;
        min-width: 70px;
        max-width: 70px;
    }
    
    .period-table .total-col {
        right: 200px;
        width: 70px;
        min-width: 70px;
        max-width: 70px;
    }
    
    .period-table .total-col.actual-col {
        right: 270px;
    }
    
    .period-table .actual-col:not(.total-col),
    .period-table .balance-col:not(.total-col) {
        width: 60px;
        min-width: 60px;
        max-width: 60px;
    }
}

/* תיקון סופי - רקע אחיד לכל עמודות הסיכום בכותרת */
.period-table.monthly-view thead th.summary-col {
    background: #dbeafe !important;
}

.period-table.quarterly-view thead th.summary-col {
    background: #dbeafe !important;
}

/* תיקון sticky לכותרת סה"כ שנתי בתצוגה רבעונית */
.period-table.quarterly-view thead tr:first-child .summary-header {
    background: #dbeafe !important;
    position: sticky;
    right: 160px;
    z-index: 11;
}

/* תיקון sticky לתקציב רבעוני בשורה הראשונה */
.period-table.quarterly-view thead tr:first-child .periodic-budget-col {
    background: #fef9c3 !important;
    position: sticky;
    z-index: 11;
}

/* רקע מלא לשורות הכותרת הקבועות */
.period-table.quarterly-view thead tr:first-child th:first-child {
    background: #f8fafc !important;
    position: sticky;
    right: 0;
    z-index: 12;
}

.period-table.quarterly-view thead tr:nth-child(2) th:first-child {
    background: #f8fafc !important;
    position: sticky;
    right: 0;
    z-index: 12;
}

/* כותרות משניות (תקציב, ביצוע, יתרה) בשורה השנייה - צבע אחיד */
.period-table.quarterly-view thead tr:nth-child(2) th.summary-col {
    background: #dbeafe !important;
}

.period-table.quarterly-view thead tr:nth-child(2) th.summary-col.budget-summary,
.period-table.quarterly-view thead tr:nth-child(2) th.summary-col.actual-summary,
.period-table.quarterly-view thead tr:nth-child(2) th.summary-col.balance-summary {
    background: #dbeafe !important;
}

/* סגנונות sticky לעמודות סיכום */
.period-table.quarterly-view .summary-col.budget-summary,
.period-table.quarterly-view .summary-col.actual-summary,
.period-table.quarterly-view .summary-col.balance-summary {
    position: sticky;
    z-index: 10;
    background: #dbeafe;
}

.period-table.quarterly-view tbody td.summary-col {
    position: sticky;
    z-index: 5;
    background: white;
}

/* עמודת תקציב רבעוני - צבע צהוב */
.period-table.quarterly-view .periodic-budget-col {
    background: #fef9c3 !important;
}

.period-table.quarterly-view thead .periodic-budget-col {
    background: #fef9c3 !important;
}

.period-table.quarterly-view tbody .periodic-budget-col {
    background: #fefce8 !important;
}

/* ===== Upload Status ===== */
.upload-status {
    position: fixed;
    top: 75px;
    left: 20px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: none;
    animation: fadeIn 0.3s ease;
}

/* ===== Status Message (for refresh and upload) ===== */
.status-message {
    position: fixed;
    top: 75px;
    left: 20px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: none;
    animation: slideIn 0.3s ease;
}

.status-message.success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.status-message.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.status-message.info {
    background: linear-gradient(135deg, #7BC5D6, #9B6DB5);
    color: white;
}

@keyframes slideIn {
    from { 
        opacity: 0; 
        transform: translateX(-20px); 
    }
    to { 
        opacity: 1; 
        transform: translateX(0); 
    }
}

/* ===== Export Button ===== */
/* ===== Modal Styles ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #64748b;
}

.modal-body p {
    margin: 0 0 12px 0;
    color: #475569;
    line-height: 1.6;
}

.modal-body .info-text {
    color: #64748b;
    font-size: 0.9rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.modal .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal .btn-secondary {
    background: #f1f5f9;
    color: #64748b;
}

.modal .btn-secondary:hover {
    background: #e2e8f0;
}

.modal .btn-cancel {
    background: #fee2e2;
    color: #dc2626;
}

.modal .btn-cancel:hover {
    background: #fecaca;
}

.modal .btn-primary {
    background: linear-gradient(145deg, #7BC5D6, #9B6DB5);
    color: white;
}

.modal .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(123, 197, 214, 0.4);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.upload-status.info {
    background: linear-gradient(135deg, #7BC5D6, #9B6DB5);
    color: white;
}

.upload-status.success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.upload-status.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

/* ===== View Mode Selector (Categories vs Departments) ===== */
.view-mode-selector {
    background: transparent;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: -10px;
    margin-bottom: 20px;
}

.view-mode-label {
    font-size: 15px;
    font-weight: 500;
    color: #64748b;
}

.slider-toggle {
    position: relative;
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
}

.slider-bg {
    position: absolute;
    top: 4px;
    right: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: linear-gradient(135deg, #9B6DB5, #7BC5D6);
    border-radius: 8px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(155, 109, 181, 0.3);
}

.slider-toggle.departments .slider-bg {
    right: calc(50%);
}

.slider-btn {
    position: relative;
    z-index: 1;
    padding: 10px 28px;
    font-size: 15px;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Rubik', sans-serif;
    border-radius: 8px;
}

.slider-btn.active {
    color: white;
    font-weight: 600;
}

.slider-btn:hover:not(.active) {
    color: #475569;
}

@media (max-width: 768px) {
    .view-mode-selector {
        padding: 15px 20px;
        gap: 12px;
    }
    
    .view-mode-label {
        font-size: 14px;
    }
    
    .slider-btn {
        padding: 8px 20px;
        font-size: 14px;
    }
}

/* ===== Department View Specific Styles ===== */
.department-section .category-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.department-title-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.department-title-wrapper h3 {
    margin: 0;
    font-size: 18px;
}

.department-manager {
    font-size: 13px;
    font-weight: 400;
    color: #64748b;
    opacity: 0.9;
}

.department-section .category-totals {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

/* Department Summary Section */
.departments-summary-section {
    background: linear-gradient(145deg, #ffffff, #fafbfc);
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: 
        0 4px 25px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.8);
    position: relative;
    overflow: hidden;
}

.departments-summary-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #10b981, #7BC5D6, #9B6DB5, #ef4444);
}

.departments-summary-section .summary-header {
    text-align: center;
    margin-bottom: 20px;
}

.departments-summary-section .summary-header h2 {
    color: #1e293b;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

.departments-summary-section .summary-header p {
    color: #64748b;
    font-size: 14px;
    margin: 4px 0 0 0;
}

/* Department Summary Table */
.dept-summary-table {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.dept-summary-header {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.2fr 1.2fr 1.2fr 1.5fr;
    background: linear-gradient(135deg, rgba(155, 109, 181, 0.08), rgba(123, 197, 214, 0.08));
    border-bottom: 2px solid #e2e8f0;
    padding: 0;
}

.dept-summary-header .header-cell {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    text-align: right;
}

.dept-summary-header .dept-name-header {
    text-align: right;
}

.dept-summary-body {
    background: white;
}

.dept-summary-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1.2fr 1.2fr 1.2fr 1.5fr;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    align-items: center;
}

.dept-summary-row:hover {
    background: #f8fafc;
}

.dept-summary-row:last-child {
    border-bottom: none;
}

/* Department Name Cell */
.dept-name-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
}

.dept-color-indicator {
    width: 4px;
    height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
}

.dept-name {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}

/* Manager Cell */
.dept-manager-cell {
    padding: 16px 20px;
    text-align: right;
}

.dept-manager-cell .cell-value {
    font-weight: 400;
    color: #64748b;
}

/* Value Cells */
.dept-budget-cell,
.dept-actual-cell,
.dept-balance-cell {
    padding: 16px 20px;
    text-align: right;
}

.cell-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
    display: none; /* Hidden on desktop, shown on mobile */
}

.cell-value {
    font-size: 14px;
    font-weight: 400;
    color: #334155;
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

.cell-value.positive {
    color: #10b981;
}

.cell-value.negative {
    color: #ef4444;
}

/* Progress Cell */
.dept-progress-cell {
    padding: 16px 20px;
}

.progress-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-text {
    display: flex;
    justify-content: center;
}

.progress-bar-container {
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
    width: 100%;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Responsive */
@media (max-width: 1024px) {
    .department-section .category-totals {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .dept-summary-header,
    .dept-summary-row {
        grid-template-columns: 1.2fr 0.8fr 1fr 1fr 1fr 1.2fr;
    }
}

@media (max-width: 768px) {
    .department-title-wrapper h3 {
        font-size: 16px;
    }
    
    .department-manager {
        font-size: 12px;
    }
    
    .dept-summary-header {
        display: none; /* Hide header on mobile */
    }
    
    .dept-summary-row {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 12px;
    }
    
    .dept-summary-row:last-child {
        margin-bottom: 0;
    }
    
    .dept-name-cell,
    .dept-manager-cell,
    .dept-budget-cell,
    .dept-actual-cell,
    .dept-balance-cell,
    .dept-progress-cell {
        padding: 0;
    }
    
    .cell-label {
        display: block; /* Show labels on mobile */
    }
    
    .dept-manager-cell,
    .dept-budget-cell,
    .dept-actual-cell,
    .dept-balance-cell {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .dept-manager-cell::before {
        content: 'אחראי/ת';
        font-size: 11px;
        color: #94a3b8;
    }
    
    .progress-content {
        gap: 6px;
    }
    
    .progress-text {
        justify-content: flex-start;
    }
}

.note-icon:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(155, 109, 181, 0.3);
}

.note-icon .note-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    right: 50%;
    transform: translateX(50%);
    background: linear-gradient(145deg, #ffffff, #fafbfc);
    color: #1e293b;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    white-space: pre-wrap;
    min-width: 200px;
    max-width: 350px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    z-index: 1000;
    transition: all 0.2s ease;
    pointer-events: none;
}

.note-icon .note-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX(50%);
    border: 6px solid transparent;
    border-top-color: #ffffff;
}

.note-icon:hover .note-tooltip {
    visibility: visible;
    opacity: 1;
    bottom: 135%;
}

.note-tooltip-title {
    font-weight: 600;
    color: #9B6DB5;
    margin-bottom: 6px;
    font-size: 12px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .note-icon .note-tooltip {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        max-width: 250px;
    }
    
    .note-icon .note-tooltip::after {
        right: auto;
        left: 50%;
    }
}

/* ===== Item Notes Tooltip ===== */
.note-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    background: #e0e7ff;
    color: #6366f1;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 600;
    cursor: help;
    position: relative;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.note-icon:hover {
    opacity: 1;
    background: #c7d2fe;
    transform: scale(1.1);
}

.note-icon .note-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 125%;
    right: 50%;
    transform: translateX(50%);
    background: linear-gradient(145deg, #ffffff, #fafbfc);
    color: #1e293b;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    white-space: pre-wrap;
    min-width: 200px;
    max-width: 350px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    z-index: 99999;
    transition: all 0.2s ease;
    pointer-events: none;
}

.note-icon .note-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX(50%);
    border: 6px solid transparent;
    border-top-color: #ffffff;
    z-index: 99999;
}

.note-icon:hover .note-tooltip {
    visibility: visible;
    opacity: 1;
    bottom: 135%;
}

.note-tooltip-title {
    font-weight: 600;
    color: #6366f1;
    margin-bottom: 6px;
    font-size: 12px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .note-icon .note-tooltip {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        max-width: 250px;
    }
    
    .note-icon .note-tooltip::after {
        right: auto;
        left: 50%;
    }
}

/* תיקון הסתרת טולטיפ מתחת לכותרות */
.item-name,
.period-item-name {
    position: relative;
    overflow: visible !important;
}

.note-icon {
    z-index: 100000 !important;
}

.note-icon .note-tooltip {
    z-index: 100001 !important;
}

/* ===== Logout Button ===== */
.logout-fab {
    background: linear-gradient(145deg, #ef4444, #dc2626) !important;
    color: white !important;
}

.logout-fab:hover {
    background: linear-gradient(145deg, #dc2626, #b91c1c) !important;
    transform: translateY(-3px) !important;
}


.logout-button {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    color: #64748b;
    font-family: 'Rubik', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.logout-button:hover {
    background: linear-gradient(145deg, #fee2e2, #fecaca);
    border-color: #f87171;
    color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.logout-button svg {
    flex-shrink: 0;
}

.logout-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .logout-button span {
        display: none;
    }
    .logout-button {
        padding: 10px;
        left: 10px;
        top: 10px;
    }
}


.fab-logout:hover {
    background: linear-gradient(145deg, #fecaca, #fca5a5) !important;
    border-color: #f87171 !important;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3) !important;
}

.fab-logout svg {
    stroke: #dc2626;
}

/* ===== Temp Entries ===== */
.temp-entry-row {
    background-color: #fff5f5 !important;
    border-right: 3px solid #ef4444;
}
.temp-entry-row td {
    color: #b91c1c;
}
.temp-badge {
    display: inline-block;
    background: #fecaca;
    color: #b91c1c;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: bold;
}
.temp-note {
    color: #9ca3af;
    font-size: 11px;
}
.temp-cat-indicator {
    color: #ef4444;
    font-size: 14px;
    margin-right: 6px;
    cursor: help;
}
.add-temp-btn {
    background: transparent;
    border: 1.5px solid #6b7280;
    color: #374151;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.add-temp-btn:hover {
    background: #374151;
    color: white;
}
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s;
}
.icon-btn:hover {
    background: #f3f4f6;
}

.temp-item-indicator {
    font-size: 11px;
    color: #ef4444;
    margin-right: 5px;
    opacity: 0.8;
    cursor: help;
}

/* ===== Control Bar - שורת סינון מאוחדת ===== */
.control-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-top: 20px;
    padding: 10px 24px;
    margin: 0 auto 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.07);
    width: fit-content;
    max-width: 95%;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 20px;
}

.control-label {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.control-divider {
    width: 1px;
    height: 28px;
    background: #e2e8f0;
}

.control-pills {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
}

.control-pill {
    padding: 5px 14px;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Rubik', sans-serif;
    white-space: nowrap;
}

.control-pill:hover:not(.active) {
    color: #475569;
    background: rgba(255,255,255,0.6);
}

.control-pill.active {
    background: linear-gradient(135deg, #9B6DB5, #7BC5D6);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(155, 109, 181, 0.3);
}

/* התאמת slider-toggle בתוך control-bar */
.control-bar .slider-toggle {
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
}

.control-bar .slider-btn {
    padding: 5px 14px;
    font-size: 13px;
}

/* הסתרת year-selector ו-view-mode-selector הישנים */
.year-selector,
.view-mode-selector {
    display: none !important;
}

@media (max-width: 768px) {
    .control-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 10px 12px;
    }
    .control-divider { display: none; }
    .control-group { padding: 4px 8px; }
}

/* ===== תיקון slider 3 כפתורים (פריסה) ===== */
#layoutToggle .slider-bg {
    width: calc(33.33% - 4px) !important;
    right: 4px;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1), width 0.35s;
}

#layoutToggle .slider-btn {
    width: calc(33.33%);
    min-width: 56px;
}

/* תיקון yearToggle - ברירת מחדל slider ב-2025 */
#yearToggle .slider-bg {
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* כפתורי פריסה בתוך הסטריפ */
.floating-toolbar.has-period-selector .view-icons {
    display: flex !important;
}

/* הסתרת fab הפריסה */
#viewToggleBtn {
    display: none !important;
}

/* הסתרת toolbar כשאין בחירת תקופה */
.floating-toolbar:not(.has-period-selector) {
    display: none !important;
}

/* סטריפ תקופה - sticky בראש ה-container, לא צף */
.floating-toolbar.has-period-selector {
    display: flex !important;
    position: sticky;
    top: 0;
    transform: none;
    z-index: 200;
    width: 100%;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 8px 20px;
    justify-content: center;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 20px;         /* רווח מתחת לסטריפ */
}

.container.period-view {
    padding-top: 0;
}

/* ===== שיוך סעיף לא ממויין ===== */
.assign-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    margin-left: 6px;
    transition: background 0.2s;
    vertical-align: middle;
}
.assign-btn:hover {
    background: #059669;
}
.assign-account-info {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
}
.assign-info-row {
    display: flex;
    gap: 12px;
    padding: 4px 0;
    font-size: 13px;
}
.assign-info-label {
    color: #64748b;
    font-weight: 500;
    min-width: 110px;
}
.assign-info-value {
    color: #1e293b;
    font-weight: 600;
}

.delete-unassigned-btn {
    cursor: pointer;
    margin-right: 4px;
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.2s;
    vertical-align: middle;
}
.delete-unassigned-btn:hover {
    opacity: 1;
}

.delete-item-btn {
    background: transparent;
    border: 1.5px solid #ef4444;
    color: #ef4444;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}
.delete-item-btn:hover {
    background: #ef4444;
    color: white;
}

/* ===== עמודת אחוז ברבעוני ===== */
.pct-col {
    text-align: center;
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    font-size: 12px;
    white-space: nowrap;
}

/* רוחב אחיד לכל עמודות הרבעון כדי שהכותרת תהיה ממורכזת */
.period-table .actual-col,
.period-table .balance-col {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    box-sizing: border-box;
}

/* ===== סיכום רבעוני ===== */
.quarterly-summary-card {
    background: white;
    overflow: visible;
    width: max-content;
    min-width: 100%;
}

.quarterly-summary-section-HIDDEN {
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    margin-bottom: 8px;
    border: 2px solid #bfdbfe;
    overflow: visible;
}

.qs-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.qs-table th {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
    padding: 10px 14px;
    text-align: center;
    border-bottom: 2px solid #e2e8f0;
    font-size: 12px;
    white-space: nowrap;
}

.qs-table td {
    padding: 10px 14px;
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}

.qs-label {
    text-align: right !important;
    min-width: 130px;
    font-weight: 600;
}

.qs-total-header { background: #dbeafe !important; }
.qs-q-header    { background: #f8fafc !important; font-weight: 700 !important; color: #1e40af !important; }
/* עמודות qs — אותם רוחבים כמו הטבלה הרבעונית */
.qs-budget-col   { width: 80px; min-width: 80px; max-width: 80px; text-align: center; }
.qs-qbudget-col  { width: 80px; min-width: 80px; max-width: 80px; text-align: center; background: #fef9c3; border-right: 2px solid #e2e8f0; border-left: 2px solid #e2e8f0; }
.qs-actual-col   { width: 80px; min-width: 80px; max-width: 80px; text-align: center; }
.qs-balance-col  { width: 80px; min-width: 80px; max-width: 80px; text-align: center; }
.qs-pct-col      { width: 58px; min-width: 58px; max-width: 58px; text-align: center; }
.qs-label        { min-width: 160px; }

.qs-income-row  td { background: #f0fdf4; }
.qs-expense-row td { background: #fff7ed; }
.qs-net-row     td { background: #eff6ff; font-weight: 700; font-size: 14px; border-top: 2px solid #bfdbfe; }

.qs-table .positive { color: #16a34a; font-weight: 600; }
.qs-table .negative { color: #dc2626; font-weight: 600; }

.qs-table .month-sep { border-left: 2px solid #cbd5e1; }

.quarterly-summary-section { display: none !important; }

/* ===== כרטיסיות יתרה רבעונית ===== */
.quarterly-balance-cards {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.quarterly-balance-card {
    flex: 1;
    min-width: 180px;
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
}

.qbc-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e40af;
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #dbeafe;
}

.qbc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
}

.qbc-label {
    color: #64748b;
    font-weight: 500;
}

.qbc-value {
    font-weight: 600;
    font-size: 14px;
}

.income-color  { color: #0ea5e9; }
.expense-color { color: #f97316; }

.qbc-divider {
    border-top: 1px dashed #e2e8f0;
    margin: 8px 0;
}

.qbc-balance-row {
    margin-bottom: 0;
}

.qbc-balance-row .qbc-label {
    font-weight: 700;
    color: #334155;
}

.qbc-balance-row .qbc-value {
    font-size: 16px;
    font-weight: 700;
}

/* תנועה זמנית בתצוגה חודשית/רבעונית */
.transaction-row.temp-transaction {
    background: #fff5f5;
    border-right: 2px solid #ef4444;
    border-radius: 4px;
    padding-right: 4px !important;
}
.transaction-row.temp-transaction .trans-desc {
    color: #b91c1c;
}
.transaction-row.temp-transaction .trans-amount {
    color: #b91c1c;
    font-weight: 600;
}

/* copy-inline — גלוי להעתקה אבל בלתי נראה ויזואלית */
.copy-inline {
    position: absolute;
    left: -9999px;
    font-size: 0;
    user-select: text;
}

/* הסתר trans-desc ו-trans-amount מהעתקה */
.transaction-row {
    position: relative;
}

/* ===== פיצול לפי כרטסות ===== */
.accounts-breakdown-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    margin-right: 4px;
    transition: all 0.2s;
    vertical-align: middle;
    border: 1px solid #bae6fd;
}
.accounts-breakdown-btn:hover {
    background: #0369a1;
    color: white;
}
.accounts-breakdown-btn.active {
    background: #0369a1;
    color: white;
}

.accounts-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: #f8fafc;
    border-top: 1px dashed #cbd5e1;
    border-bottom: 1px dashed #cbd5e1;
}

.accounts-breakdown-table thead th {
    background: #e8f4f8;
    color: #475569;
    padding: 6px 12px;
    font-weight: 600;
    font-size: 11px;
    text-align: center;
    border-bottom: 1px solid #cbd5e1;
}

.account-breakdown-row td {
    padding: 5px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
}

.account-breakdown-row:last-child td {
    border-bottom: none;
}

.account-breakdown-row:hover td {
    background: #f0f9ff;
}

.account-breakdown-name {
    text-align: right !important;
    direction: rtl;
}

.account-key {
    display: inline-block;
    background: #e2e8f0;
    color: #64748b;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 6px;
    font-family: monospace;
}

/* ===== פיצול לפי כרטסות ===== */
.account-sub-row {
    background: #f8fafc;
    cursor: pointer;
    border-right: 3px solid #7BC5D6;
}
.account-sub-row:hover td {
    background: #e0f2fe;
}
.account-sub-name {
    padding-right: 28px !important;
    font-size: 12px;
    color: #334155;
}
.account-expand-icon {
    display: inline-block;
    width: 14px;
    font-size: 10px;
    color: #7BC5D6;
    margin-left: 4px;
    transition: transform 0.2s;
}
.account-key {
    display: inline-block;
    background: #e2e8f0;
    color: #64748b;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 6px;
    font-family: monospace;
}
.account-details-row td {
    padding: 0 !important;
    background: #f0f9ff;
}
.account-details-cell {
    padding: 0 !important;
}
.account-details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.account-details-table td {
    padding: 4px 16px 4px 8px;
    border-bottom: 1px solid #e2e8f0;
    color: #475569;
}
.account-details-table tr:last-child td {
    border-bottom: none;
}

/* ===== כותרת קבוצת כרטסת בפיצול ===== */
.account-group-header {
    background: linear-gradient(135deg, #e8f4f8, #f0f9ff);
    border-top: 2px solid #7BC5D6;
    border-bottom: 1px solid #bae6fd;
}
.account-group-header:first-child {
    border-top: none;
}
.account-group-name {
    padding: 7px 12px !important;
    font-weight: 700;
    font-size: 12px;
    color: #0369a1;
    text-align: right;
    width: auto;
}
.account-group-cell {
    padding: 7px 12px 7px 20px !important;
    font-weight: 600;
    font-size: 12px;
    text-align: left;
    direction: ltr;
    white-space: nowrap;
    min-width: 110px;
}

.account-group-header {
    cursor: pointer;
}
.account-group-header:hover td {
    background: #dbeafe !important;
}
.acc-group-arrow {
    display: inline-block;
    font-size: 10px;
    color: #7BC5D6;
    margin-left: 6px;
    transition: transform 0.2s;
}

/* העתקה לclipboard */
.copy-trigger {
    cursor: copy;
}
.copy-trigger:hover {
    background: rgba(59, 130, 246, 0.08);
}
.copy-trigger:active {
    background: rgba(59, 130, 246, 0.18);
}

#copy-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Rubik', sans-serif;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 9999;
    white-space: nowrap;
}
#copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== עמינדב - סיכום מחלקות ===== */
.aminadav-summary {
    margin-bottom: 24px;
}
.summary-cards-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}
.summary-card.planned { border-top: 3px solid #3b82f6; }
.summary-card.planned .card-value { color: #1e40af; }
.summary-card.actual { border-top: 3px solid #f59e0b; }
.summary-card.actual .card-value { color: #d97706; }
.summary-card.balance { border-top: 3px solid #10b981; }
.summary-card.balance .card-value { color: #059669; }
.summary-card.balance.negative { border-top-color: #ef4444; }
.summary-card.balance.negative .card-value { color: #dc2626; }
.summary-progress-wrap { padding: 0 4px; }
.summary-progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}
.summary-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s ease;
}
.summary-progress-fill.good    { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.summary-progress-fill.warning { background: linear-gradient(90deg, #f59e0b, #d97706); }
.summary-progress-fill.danger  { background: linear-gradient(90deg, #ef4444, #dc2626); }
.summary-progress-label { font-size: 12px; color: #6b7280; text-align: left; }

/* ===== עמינדב - סיכום שנתי משופר ===== */
.aminadav-yearly-summary {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.ays-total-bar {
    padding: 22px 28px 18px;
    background: linear-gradient(135deg, #f8faff 0%, #fff 100%);
    border-bottom: 1px solid #f0f0f0;
}
.ays-total-nums {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.ays-total-item { display: flex; flex-direction: column; gap: 4px; }
.ays-total-label { font-size: 11px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: .5px; }
.ays-total-val { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ays-total-val.budget { color: #1e40af; }
.ays-total-val.actual { color: #d97706; }
.ays-total-val.pos { color: #059669; }
.ays-total-val.neg { color: #dc2626; }
.ays-pct-item { margin-right: auto; text-align: center; }
.ays-main-bar {
    height: 14px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}
.ays-main-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .7s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-left: 8px;
    min-width: 40px;
}
.ays-main-bar-fill.good    { background: linear-gradient(90deg,#93c5fd,#3b82f6); }
.ays-main-bar-fill.warning { background: linear-gradient(90deg,#fcd34d,#f59e0b); }
.ays-main-bar-fill.danger  { background: linear-gradient(90deg,#fca5a5,#ef4444); }
.ays-bar-label { font-size: 10px; font-weight: 700; color: #fff; white-space: nowrap; }

/* שורות מחלקה */
.ays-dept-breakdown { padding: 0 28px 16px; }
.ays-dept-header {
    display: flex;
    align-items: center;
    padding: 10px 0 6px;
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 4px;
}
.ays-dept-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f9fafb;
}
.ays-dept-row:last-child { border-bottom: none; }
.ays-dept-name { font-size: 14px; font-weight: 700; color: #1f2937; min-width: 80px; }
.ays-dept-nums, .ays-dept-nums-header {
    display: flex;
    gap: 20px;
    flex: 1;
}
.ays-dept-nums-header { font-size: 10px; color: #9ca3af; font-weight: 600; flex: 1; }
.ays-dept-nums-header span { flex: 1; text-align: center; }
.ays-num { flex: 1; text-align: center; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ays-num.budget { color: #3b82f6; }
.ays-num.actual { color: #d97706; }
.ays-num.pos { color: #059669; }
.ays-num.neg { color: #dc2626; }
.ays-dept-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.ays-dept-bar { flex: 1; height: 6px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.ays-dept-bar-fill { height: 100%; border-radius: 99px; transition: width .5s; }
.ays-dept-pct { font-size: 11px; font-weight: 700; min-width: 34px; text-align: left; }

/* ===== עמינדב - כרטיסי תקופה (חודשי/רבעוני) ===== */
.aminadav-period-summary {
    background: linear-gradient(135deg,#f0f7ff,#fff);
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 18px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
}
.aps-totals { display: flex; gap: 28px; flex-wrap: wrap; }
.aps-item { display: flex; flex-direction: column; gap: 3px; }
.aps-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.aps-val.budget { color: #1e40af; }
.aps-val.actual { color: #d97706; }
.aps-val.pos { color: #059669; }
.aps-val.neg { color: #dc2626; }
.aps-label { font-size: 11px; color: #9ca3af; font-weight: 600; }
.aps-bar-wrap { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 10px; }
.aps-bar { flex: 1; height: 10px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.aps-bar-fill { height: 100%; border-radius: 99px; transition: width .6s; }
.aps-bar-fill.good    { background: linear-gradient(90deg,#93c5fd,#3b82f6); }
.aps-bar-fill.warning { background: linear-gradient(90deg,#fcd34d,#f59e0b); }
.aps-bar-fill.danger  { background: linear-gradient(90deg,#fca5a5,#ef4444); }
.aps-pct { font-size: 13px; font-weight: 700; color: #374151; white-space: nowrap; }

.aminadav-period-cards {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.aminadav-period-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    min-width: 140px;
    flex: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    transition: box-shadow .2s;
}
.aminadav-period-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.apc-title { font-size: 13px; font-weight: 800; color: #374151; margin-bottom: 10px; }
.apc-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 12px; }
.apc-label { color: #9ca3af; font-weight: 500; }
.apc-val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.apc-val.budget { color: #2563eb; }
.apc-val.actual { color: #d97706; }
.apc-val.pos { color: #059669; }
.apc-val.neg { color: #dc2626; }
.apc-divider { height: 1px; background: #f3f4f6; margin: 7px 0; }
.apc-bar { height: 4px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin-top: 10px; margin-bottom: 4px; }
.apc-bar-fill { height: 100%; border-radius: 99px; transition: width .5s; }
.apc-bar-fill.good    { background: #3b82f6; }
.apc-bar-fill.warning { background: #f59e0b; }
.apc-bar-fill.danger  { background: #ef4444; }
.apc-pct { font-size: 10px; color: #9ca3af; text-align: left; font-weight: 600; }

@media(max-width:640px) {
    .ays-total-nums { gap: 16px; }
    .ays-total-val { font-size: 18px; }
    .ays-dept-breakdown { padding: 0 16px 12px; }
    .aminadav-period-card { min-width: 120px; }
    .aminadav-period-summary { padding: 14px 16px; gap: 16px; }
}

/* ===== עמינדב - יישור מספרים ושיפורים ===== */

/* יישור מספרים לימין עם tabular-nums */
.item-amount,
.category-total-value,
.ays-num,
.ays-total-val,
.aps-val,
.apc-val {
    text-align: right !important;
    font-variant-numeric: tabular-nums !important;
    font-feature-settings: "tnum" !important;
}

/* עמודות מספרים בטבלה - רוחב קבוע ויישור */
.items-table th:not(:first-child),
.items-table td.item-amount {
    text-align: right !important;
    width: 130px;
    min-width: 110px;
}

/* כותרת category - שדרוג עם progress bar */
.category-header {
    position: relative;
    overflow: hidden;
}
.category-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    height: 3px;
    background: rgba(0,0,0,.12);
    width: 100%;
}

/* סיכום מחלקה בheader - יישור מספרים */
.category-totals {
    display: flex;
    gap: 24px;
    align-items: flex-end;
}
.category-total-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 90px;
}
.category-total-label {
    font-size: 10px;
    font-weight: 600;
    opacity: .7;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 2px;
}
.category-total-value {
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* הוסף progress bar מתחת לheader */
.category-section .category-progress-bar {
    height: 4px;
    background: rgba(0,0,0,.08);
    margin: 0;
}
.category-section .category-progress-fill {
    height: 100%;
    transition: width .6s ease;
}

/* סיכום שורה בטבלה */
.summary-row td {
    font-weight: 700 !important;
    background: rgba(0,0,0,.03);
    border-top: 2px solid rgba(0,0,0,.08) !important;
}
.summary-row td.item-amount {
    text-align: right !important;
}

/* הסתר כפתורי עריכה שלא רלוונטיים */
.edit-icon, .assign-btn, .delete-unassigned-btn, .add-temp-btn {
    display: none !important;
}

/* ays - יישור עמודות header */
.ays-dept-header {
    display: grid;
    grid-template-columns: 100px 1fr 130px;
}
.ays-dept-row {
    display: grid;
    grid-template-columns: 100px 1fr 130px;
}
.ays-dept-nums,
.ays-dept-nums-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
}
.ays-num,
.ays-dept-nums-header span {
    text-align: right;
    padding-left: 12px;
}

/* period summary - יישור */
.aps-totals {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 28px;
}
.aps-val {
    text-align: right;
}

/* ===== progress bar בשורת סעיף (שנתי) ===== */
.item-progress-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}
.item-progress-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
    min-width: 0;
}
.item-progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .5s ease;
}
.item-progress-fill.good    { background: linear-gradient(90deg, #93c5fd, #3b82f6); }
.item-progress-fill.warning { background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.item-progress-fill.danger  { background: linear-gradient(90deg, #fca5a5, #ef4444); }
.item-progress-pct {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    white-space: nowrap;
    text-align: left;
}

/* ===== כרטיסיות תקופה - מקסימום 6 בשורה (חודשי בלבד) ===== */
.monthly-view .aminadav-period-cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}
@media (max-width: 900px) {
    .monthly-view .aminadav-period-cards { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
    .monthly-view .aminadav-period-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ===== סיכום מחלקות (למעלה - כל תצוגה) ===== */
.aminadav-dept-summary-box {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    margin-left: -1px;
    margin-right: -1px;
}
.adsb-header {
    display: grid;
    grid-template-columns: 247px 201px 201px 201px 1fr;
    padding: 8px 0;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .5px;
    gap: 0;
}
.dept-summary-row {
    display: grid;
    grid-template-columns: 247px 201px 201px 201px 1fr;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
    transition: background .15s;
    gap: 0;
}
.dept-summary-row:last-child { border-bottom: none; }
.dept-summary-row:hover { background: #fafbff; }
.dsr-name {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 12px 0 12px;
}
.dsr-nums, .dsr-nums-header {
    display: contents; /* מאפשר לכל תא להיות חלק מה-grid הראשי */
}
.dsr-nums-header span {
    text-align: right;
    font-size: 10px;
    color: #9ca3af;
    padding: 0 25px;
}
.dsr-num {
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 0 25px;
    direction: ltr;
}
.dsr-num.budget { color: #2563eb; }
.dsr-num.actual { color: #d97706; }
.dsr-num.pos    { color: #059669; }
.dsr-num.neg    { color: #dc2626; }
.dsr-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 4px;
}
.dsr-bar {
    flex: 1;
    height: 7px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
}
.dsr-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .5s ease;
}
.dsr-pct {
    font-size: 11px;
    font-weight: 700;
    min-width: 34px;
    text-align: left;
}

/* ===== כותרת מחלקה מעל כרטיסיות תקופה ===== */
.dept-period-block {
    margin-bottom: 24px;
}
.dept-period-title {
    font-size: 15px;
    font-weight: 800;
    color: #1f2937;
    padding: 10px 4px 8px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 12px;
}

/* ===== כרטיסיות תקופה inline (מעל מחלקה) ===== */
.dept-period-block-inline {
    margin-bottom: 12px;
}
.dept-period-block-inline .aminadav-period-cards {
    margin-bottom: 0;
}

/* ===== Department Filter Dropdown ===== */
.dept-filter-select {
    font-family: 'Rubik', 'Heebo', sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 14px;
    border: none;
    border-radius: 7px;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    outline: none;
    transition: all .2s;
    min-width: 130px;
    direction: rtl;
    appearance: auto;
}
.dept-filter-select:hover {
    background: #e2e8f0;
    color: #475569;
}
.dept-filter-select:focus {
    background: white;
    box-shadow: 0 0 0 2px rgba(155,109,181,.3);
    color: #1e293b;
}
#deptFilterGroup {
    border-right: 1px solid #e2e8f0;
    padding-right: 20px;
}
