/* ===== מודלים ===== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal.hidden {
    display: none;
}

.modal-box {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 22rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: pop 0.2s ease-out;
}

.month-seed-buffer-box {
    width: min(52rem, 96vw);
    max-height: 86vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.month-seed-buffer-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.month-seed-buffer-kpi {
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    border-radius: 10px;
    padding: 8px 10px;
}

.month-seed-buffer-kpi-label {
    font-size: 0.75rem;
    color: #475569;
}

.month-seed-buffer-kpi-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
}

.month-seed-buffer-sections {
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 12px;
}

.month-seed-buffer-section {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px;
    margin-bottom: 8px;
}

.month-seed-buffer-section:last-child {
    margin-bottom: 0;
}

.month-seed-buffer-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.month-seed-buffer-title {
    font-size: 0.9rem;
    font-weight: 700;
}

.month-seed-buffer-actions {
    display: flex;
    gap: 6px;
}

.month-seed-buffer-action {
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 0.75rem;
}

.month-seed-buffer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #f1f5f9;
    padding: 6px 0;
}

.month-seed-buffer-row:first-of-type {
    border-top: none;
}

.month-seed-buffer-row-label {
    flex: 1;
    font-size: 0.85rem;
}

.month-seed-buffer-row-amount {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0f172a;
}

@media (max-width: 640px) {
    .month-seed-buffer-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@keyframes pop {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 1rem;
}

.btn-cancel {
    background: #d1d5db;
    padding: 8px 16px;
    border-radius: 8px;
}

.btn-confirm {
    background: #2563eb;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
}

.btn-danger {
    background: #dc2626;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
}

.btn-success {
    background: #16a34a;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
}

/* ===== שדות ===== */

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* ===== טאב אייקונים ===== */

.tab-icon {
    cursor: pointer;
    position: relative;
}

.tooltip {
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: black;
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    white-space: nowrap;
}

.tab-icon:hover .tooltip {
    opacity: 1;
}

/* ===== טבלאות — highlight ב-hover ===== */

.hover-table tbody tr:hover {
    background-color: #f3f4f6;
}

/* ===== Popover לתשלומים ===== */

.payment-popover {
    position: absolute;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 16px;
    width: 220px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    z-index: 1000;
}

.payment-popover input,
.payment-popover select {
    margin-bottom: 10px;
}

.delete-x {
    cursor: pointer;
    color: red;
    font-size: 18px;
    padding: 0 6px;
}

.hidden {
    display: none;
}

#variable-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5); /* רקע כהה */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999; /* מעל הכול */
}

#variable-modal.hidden {
    display: none;
}

#variable-modal .modal-content {
    background: white; /* תוכן לבן */
    padding: 20px;
    border-radius: 8px;
    width: 350px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* ===== טאב סיכום — פריסה חדשה ===== */

.summary-layout {
    display: grid;
    grid-template-columns: 35% 1fr; /* טבלאות צרות, גרפים רחבים */
    gap: 24px;
    align-items: start;
    margin-top: 20px;
}

/* טבלאות בתוך טאב סיכום */
.summary-tables table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.summary-tables th,
.summary-tables td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.9rem;
}

.summary-tables tr:last-child td {
    border-bottom: none;
}

/* גרפים */
.summary-charts {
    width: 100%;
    min-height: 350px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* רספונסיבי */
@media (max-width: 768px) {
    .summary-layout {
        grid-template-columns: 1fr;
    }
}

.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 18px;
}

.sort-arrow {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.5;
}

.sort-active {
    font-weight: bold;
    color: #2563eb; /* כחול יפה */
}

/* ===== רענון עיצוב — דסקטופ בלבד ===== */

.btn {
    background: #2563eb;
    color: #fff;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn,
.btn-cancel,
.btn-confirm,
.btn-danger,
.btn-success {
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
}

.btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn-cancel,
.btn-confirm,
.btn-danger,
.btn-success {
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-cancel:hover,
.btn-confirm:hover,
.btn-danger:hover,
.btn-success:hover {
    transform: translateY(-1px);
}

.btn:disabled,
.btn-cancel:disabled,
.btn-confirm:disabled,
.btn-danger:disabled,
.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.monthly-tab-btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #374151;
    border-radius: 10px;
    padding: 8px 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.monthly-tab-btn:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
}

.monthly-tab-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.monthly-sticky-bar {
    position: sticky;
    top: 78px;
    z-index: 15;
    background: linear-gradient(180deg, rgba(243, 244, 246, 0.98), rgba(243, 244, 246, 0.92));
    backdrop-filter: blur(3px);
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
}

.monthly-sticky-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}

.monthly-sticky-row > :first-child {
    justify-self: start;
}

.monthly-sticky-row > .monthly-subtabs {
    justify-self: center;
    justify-content: center;
}

.monthly-sticky-row > .monthly-sticky-spacer {
    justify-self: end;
}

.monthly-expenses-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
}

.monthly-context-note {
    font-size: 12px;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 999px;
    padding: 6px 11px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.18);
}

.monthly-expenses-menu {
    position: relative;
}

.monthly-expenses-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 150px;
    display: none;
    flex-direction: column;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
    padding: 6px;
    z-index: 30;
}

.monthly-expenses-menu:hover .monthly-expenses-dropdown,
.monthly-expenses-menu:focus-within .monthly-expenses-dropdown {
    display: flex;
}

.monthly-expense-option {
    background: #ffffff;
    border: 1px solid transparent;
    color: #1f2937;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    transition: all 0.15s ease;
}

.monthly-expense-option:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

.monthly-expense-option.active {
    background: #2563eb;
    color: #fff;
}

.variable-expense-controls {
    position: sticky;
    top: 142px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    width: fit-content;
    margin-right: auto;
    z-index: 12;
}

.variable-expense-action {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    background: #ffffff;
    color: #1d4ed8;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.14);
    transition: all 0.18s ease;
}

.variable-expense-action:hover,
.variable-expense-action:focus-visible {
    background: #eff6ff;
    border-color: #60a5fa;
    transform: translateY(-1px);
}

.variable-expense-add {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    font-size: 26px;
    font-weight: 700;
}

.variable-expense-add:hover,
.variable-expense-add:focus-visible {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.variable-filter-menu {
    position: relative;
}

.variable-filter-icon {
    width: 18px;
    height: 18px;
}

.variable-expense-filters {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 180px;
    padding: 12px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.16);
    z-index: 20;
}

.variable-filter-menu:hover .variable-expense-filters,
.variable-filter-menu:focus-within .variable-expense-filters {
    display: flex;
}

.variable-expense-filters .input,
.variable-expense-filters .btn-cancel {
    width: 100%;
}

.fixed-expense-controls {
    position: sticky;
    top: 142px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    width: fit-content;
    margin-right: auto;
    z-index: 12;
}

.fixed-expense-action {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #bbf7d0;
    background: #ffffff;
    color: #15803d;
    box-shadow: 0 10px 20px rgba(34, 197, 94, 0.14);
    transition: all 0.18s ease;
}

.fixed-expense-action:hover,
.fixed-expense-action:focus-visible {
    background: #f0fdf4;
    border-color: #4ade80;
    transform: translateY(-1px);
}

.fixed-filter-menu {
    position: relative;
}

.fixed-filter-icon {
    width: 18px;
    height: 18px;
}

.fixed-expense-filters {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 180px;
    padding: 12px;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.16);
    z-index: 20;
}

.fixed-filter-menu:hover .fixed-expense-filters,
.fixed-filter-menu:focus-within .fixed-expense-filters {
    display: flex;
}

.fixed-expense-filters .input,
.fixed-expense-filters .btn-cancel {
    width: 100%;
}

.expense-tab-btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #374151;
    border-radius: 10px;
    padding: 8px 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.expense-tab-btn:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
}

.expense-tab-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.tab-icon.active {
    background: #eff6ff;
    border-radius: 12px;
    padding: 6px;
}

.tab-icon.active img {
    opacity: 1;
}

.hover-table thead th {
    color: #374151;
    font-weight: 700;
}

.hover-table tbody td {
    color: #111827;
}

.hover-table tbody tr {
    transition: background-color 0.15s ease;
}

.hover-table tbody tr:nth-child(even) {
    background: #fcfcfd;
}

@media (min-width: 769px) {
    body {
        background: linear-gradient(180deg, #f8fafc 0%, #f3f4f6 100%);
    }

    header {
        border-bottom: 1px solid #e5e7eb;
        backdrop-filter: blur(4px);
    }

    aside {
        border-left: 1px solid #eef2f7;
    }

    #main-content {
        max-width: 1680px;
    }

    .bg-white.p-6.rounded-xl.shadow-lg,
    .bg-white.p-4.rounded-lg.shadow,
    .bg-white.p-4.rounded-lg.shadow.mb-4 {
        border: 1px solid #eef2f7;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    }

    .summary-charts {
        border: 1px solid #eef2f7;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    }

    .investments-tab h1 {
        letter-spacing: 0.2px;
        margin-bottom: 1.25rem;
    }

    .investments-section-card {
        border: 1px solid #e8edf5;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
    }

    .investments-kpi-card {
        border: 1px solid #e8edf5;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    }

    .investments-section-header {
        border-bottom: 1px solid #eef2f7;
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
    }

    .investments-table thead th {
        font-size: 0.8rem;
        color: #6b7280;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .investments-table tbody td {
        padding-top: 0.7rem;
        padding-bottom: 0.7rem;
    }

    .investments-table tbody tr:hover {
        background: #f8fbff;
    }

    #save-balance-btn {
        min-width: 140px;
    }

    #settings .settings-card {
        border: 1px solid #e8edf5;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
    }

    #settings .settings-card h2 {
        margin-bottom: 0.9rem;
        padding-bottom: 0.55rem;
        border-bottom: 1px solid #eef2f7;
    }

    #settings .settings-card .input {
        margin-bottom: 0;
    }
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 8px;
}

.action-col {
    width: 72px;
    text-align: center;
}

.action-cell {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.action-icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #dbe2ea;
    border-radius: 999px;
    background: #f8fafc;
    color: #374151;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-icon-btn:hover {
    transform: translateY(-1px);
    background: #f1f5f9;
}

.action-icon-btn + .action-icon-btn {
    margin-right: 6px;
}

.action-icon-danger {
    color: #dc2626;
    border-color: #fecaca;
    background: #fef2f2;
}

.action-icon-danger:hover {
    background: #fee2e2;
}

.action-icon-edit {
    color: #1d4ed8;
    border-color: #bfdbfe;
    background: #eff6ff;
}

.action-icon-edit:hover {
    background: #dbeafe;
}

.action-icon-success {
    color: #15803d;
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.action-icon-success:hover {
    background: #dcfce7;
}

.credit-import-modal-box {
    width: min(1100px, 96vw);
    max-height: 90vh;
    overflow-y: auto;
}

.credit-import-toolbar {
    display: grid;
    grid-template-columns: 0.8fr 0.9fr 1fr 1.4fr auto;
    gap: 10px;
    align-items: center;
}

.credit-import-summary {
    margin-bottom: 14px;
}

.credit-import-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.credit-stat {
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px;
}

.credit-stat-label {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.credit-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.credit-stat-ok {
    border-color: #86efac;
    background: #f0fdf4;
}

.credit-stat-warn {
    border-color: #fdba74;
    background: #fff7ed;
}

.credit-import-section {
    margin-top: 12px;
}

.credit-collapsible {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
}

.credit-collapsible-summary {
    cursor: pointer;
    list-style: none;
    font-size: 15px;
    font-weight: 700;
    padding: 10px 12px;
    color: #1f2937;
    background: #f8fafc;
}

.credit-collapsible-summary::-webkit-details-marker {
    display: none;
}

.credit-collapsible[open] .credit-collapsible-summary {
    border-bottom: 1px solid #e5e7eb;
}

.credit-section-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #1f2937;
}

.credit-import-table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.credit-import-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.credit-import-table th,
.credit-import-table td {
    border-bottom: 1px solid #f1f5f9;
    padding: 8px;
    text-align: right;
    white-space: nowrap;
}

.credit-import-table th {
    background: #f8fafc;
    color: #334155;
    position: sticky;
    top: 0;
}

@media (max-width: 900px) {
    .monthly-sticky-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .monthly-sticky-spacer {
        display: none;
    }

    .variable-expense-controls {
        top: auto;
        margin-right: 0;
        width: 100%;
        align-items: stretch;
        position: static;
    }

    .fixed-expense-controls {
        top: auto;
        margin-right: 0;
        width: 100%;
        align-items: stretch;
        position: static;
    }

    .variable-filter-menu {
        width: 100%;
    }

    .fixed-filter-menu {
        width: 100%;
    }

    .variable-expense-filters {
        position: static;
        display: flex;
        width: 100%;
        box-shadow: none;
    }

    .fixed-expense-filters {
        position: static;
        display: flex;
        width: 100%;
        box-shadow: none;
    }

    .credit-import-toolbar {
        grid-template-columns: 1fr;
    }

    .credit-import-summary-grid {
        grid-template-columns: 1fr 1fr;
    }
}