/* ============================================ */
/* CSS Variables - Theme Colors                */
/* ============================================ */
:root {
    --primary: #07747e;
    --primary-hover: #055e67;
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --border: #e2e8f0;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --success: #48bb78;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
}

[data-theme="dark"] {
    --primary: #0abac2;
    --primary-hover: #08a0a8;
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --border: #4a5568;
}

[data-theme="amoled"] {
    --primary: #0abac2;
    --primary-hover: #08a0a8;
    --bg-primary: #000000;
    --bg-secondary: #0f0f0f;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --border: #2d3748;
}

/* Prevent layout jump when opening modals (stable scrollbar) */
html {
  overflow-y: scroll;              /* fallback */
  scrollbar-gutter: stable;        /* modern browsers */
}

/* ============================================ */
/* Base Styles                                  */
/* ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Heebo', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    min-height: 100vh;
}

/* ============================================ */
/* Navigation Tabs                              */
/* ============================================ */
.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    border-radius: 8px 8px 0 0;
    font-size: 0.95rem;
}

.tab:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-primary);
}

/* ============================================ */
/* Icon Buttons                                 */
/* ============================================ */
.icon-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(7, 116, 126, 0.3);
}

/* ============================================ */
/* Dropdown Menus                               */
/* ============================================ */
.theme-dropdown,
.settings-dropdown {
    position: relative;
}

.theme-menu,
.settings-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    padding: 0.5rem;
    min-width: 180px;
    z-index: 1000;
}

.theme-menu button,
.settings-menu button {
    width: 100%;
    padding: 0.85rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    text-align: right;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-menu button:hover,
.settings-menu button:hover {
    background: var(--bg-primary);
    color: var(--primary);
    transform: translateX(-2px);
}

/* ============================================ */
/* Mobile Menu                                  */
/* ============================================ */
/* Mobile Menu - רק מתחת ל-768px */
.mobile-menu {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

@media (min-width: 768px) {
    .mobile-menu {
        display: none !important;
    }
}

/* Hamburger button - רק מתחת ל-768px */
@media (min-width: 768px) {
    .md\:hidden {
        display: none !important;
    }
}

.mobile-tab {
    display: block;
    width: 100%;
    padding: 0.85rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: right;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.mobile-tab:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

/* ============================================ */
/* Tab Content                                  */
/* ============================================ */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

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

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

/* ============================================ */
/* Cards                                        */
/* ============================================ */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

/* ============================================ */
/* Forms                                        */
/* ============================================ */
.form-label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: 'Heebo', sans-serif;
    font-size: 0.95rem;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(7, 116, 126, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================ */
/* Toggle Switch                                */
/* ============================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* ============================================ */
/* Buttons                                      */
/* ============================================ */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: 'Heebo', sans-serif;
    width: 100%;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(7, 116, 126, 0.4);
}

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

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    padding: 0.85rem 1.75rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Heebo', sans-serif;
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: white;
    padding: 0.85rem 1.75rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-success:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.btn-icon:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

/* ============================================ */
/* Tables                                       */
/* ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

thead {
    background: var(--bg-primary);
}

th,
td {
    padding: 1.1rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
}

td {
    font-size: 0.95rem;
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: var(--bg-primary);
}

/* ============================================ */
/* Modals                                       */
/* ============================================ */
/* Modal Overlay - Fixed */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    overflow-y: auto;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 16px;
    width: 100%;
     max-width: 850px !important;
    width: 92% !important;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: modalSlide 0.3s ease;
    position: relative;
    margin: auto;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.modal-content h2 {
    margin-bottom: 1.5rem;
    color: var(--primary);
    font-size: 1.75rem;
    font-weight: 700;
}

.modal-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--danger);
    transform: rotate(90deg);
}

/* Settings Modal - Prevent overflow */
#settingsModal .modal-content {
    max-width: 800px;
}

#settingsModal .settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

#settingsModal .settings-tab {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;  /* ← הוסף */
}

/* הוסף גם: */
#settingsModal .form-input,
#settingsModal .form-select,
#settingsModal .form-textarea {
    font-size: 0.9rem;
}

#settingsModal .grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    #settingsModal .grid-2 {
        grid-template-columns: 1fr;
    }
    
    #settingsModal .modal-content {
        width: 66% !important;
        padding: 1.25rem !important;
    }
}

/* Compact form elements in settings */
#settingsModal .form-label {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

#settingsModal .form-input,
#settingsModal .form-select {
    font-size: 0.9rem;
    padding: 0.65rem 0.85rem;
}

#settingsModal .grid-2 {
    gap: 0.875rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #settingsModal .settings-tab {
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
    }
    
    #settingsModal .form-input,
    #settingsModal .form-select {
        font-size: 0.85rem;
    }
}

/* ============================================ */
/* Toolbox Grid                                 */
/* ============================================ */
.toolbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 1.2rem;
    margin: 1.5rem 0;
}

.tool-btn {
    background: var(--bg-primary);
    border: 2px solid var(--border);
    padding: 1.2rem 0.6rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
}

.tool-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(7, 116, 126, 0.35);
    border-color: var(--primary);
}

.tool-btn i {
    display: block;
    font-size: 2.2rem;
    margin-bottom: 0.6rem;
}

/* Settings Modal - Fixed overflow */
#settingsModal .modal-content {
    max-width: 900px !important;
    width: 60vw !important;
    box-sizing: border-box;
}

#settingsModal * {
    box-sizing: border-box;
}

#settingsModal .grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

#settingsModal .card {
    padding: 1.25rem;
    box-sizing: border-box;
}

/* Mobile fix */
@media (max-width: 768px) {
    #settingsModal .modal-content {
        width: 95vw !important;
        padding: 1rem !important;
    }
    
    #settingsModal .grid-2 {
        grid-template-columns: 1fr;
    }
    
    #settingsModal .settings-tabs {
        flex-direction: column;
    }
    
    #settingsModal .settings-tab {
        width: 100%;
    }
}

/* ============================================ */
/* Stat Cards                                   */
/* ============================================ */
.stat-card {
    padding: 1.25rem;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(7, 116, 126, 0.15);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.positive {
    color: var(--success);
}

.stat-value.negative {
    color: var(--danger);
}

/* ============================================ */
/* Badges                                       */
/* ============================================ */
.badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

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

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ============================================ */
/* Settings Tabs                                */
/* ============================================ */
.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.settings-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    font-weight: 600;
}

.settings-tab.active {
    color: var(--primary);
    background: var(--bg-primary);
}

.settings-tab:hover {
    background: var(--bg-primary);
}

.settings-content {
    display: none;
}

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

/* ============================================ */
/* Tax Brackets                                 */
/* ============================================ */
.tax-brackets {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.tax-bracket-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

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

/* ============================================ */
/* Utilities                                    */
/* ============================================ */
.hidden {
    display: none !important;
}

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

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ============================================ */
/* Responsive                                   */
/* ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .toolbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .modal-content {
        padding: 1.5rem;
        width: 65%;
    }

    .tool-btn {
        padding: 1rem 0.5rem;
    }

    .tool-btn i {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .toolbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ============================================ */
/* Tailwind Utility Classes Override          */
/* ============================================ */

.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.flex-1 {
    flex: 1 1 0%;
}

.text-lg {
    font-size: 1.125rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

/* Responsive - Mobile First */
@media (min-width: 768px) {
    .md\:flex {
        display: flex !important;
    }
    
    .md\:hidden {
        display: none !important;
    }
    
    .md\:flex-row {
        flex-direction: row;
    }
}

/* Force mobile menu to hide on desktop */
@media (min-width: 768px) {
    .mobile-menu {
        display: none !important;
    }
}

/* Force hamburger to hide on desktop */
@media (min-width: 768px) {
    button.md\:hidden {
        display: none !important;
    }
}

/* ============================================ */
/* AI Chat Floating Button                     */
/* ============================================ */

#aiChatBtn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 32px rgba(7, 116, 126, 0.6);
}

#aiChatBtn:active {
    transform: scale(0.95);
}

/* Pulse animation */
@keyframes pulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(7, 116, 126, 0.4); }
    50% { box-shadow: 0 8px 32px rgba(7, 116, 126, 0.7); }
}

#aiChatBtn {
    animation: pulse 2s infinite;
}

/* Mobile adjustment */
@media (max-width: 768px) {
    #aiChatBtn {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px; /* ⬅️ שינוי משמאל לימין */
        font-size: 1.5rem;
    }
}


/* ============================================ */
/* Dashboard Widgets System                    */
/* ============================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.widget-container {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.widget-container:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: var(--primary);
}

.widget-container.edit-mode {
    border-color: var(--warning);
    border-style: dashed;
}

.widget-container.edit-mode:hover {
    background: var(--bg-primary);
}

.widget-controls {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    gap: 0.35rem;
    z-index: 10;
}

.widget-control-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--danger);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.widget-control-btn:first-child {
    background: var(--primary);
}

.widget-control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.widget-content {
    height: 100%;
}

.widget-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.widget-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.widget-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.widget-stat-large {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.widget-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Calculator Widget Styles */
.calc-btn {
    padding: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.calc-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.calc-btn:active {
    transform: scale(0.95);
}

/* Widget Size Classes */
[data-size="small"] {
    min-height: 180px;
}

[data-size="medium"] {
    min-height: 220px;
}

[data-size="large"] {
    min-height: 300px;
}

[data-size="tall"] {
    min-height: 400px;
}

[data-size="wide"] {
    min-height: 180px;
}

/* Responsive Dashboard */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    [data-size="wide"] {
        grid-column: span 3 !important;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .widget-container {
        padding: 1rem;
    }
    
    [data-size="small"],
    [data-size="medium"],
    [data-size="large"],
    [data-size="wide"] {
        grid-column: span 2 !important;
        grid-row: span 1 !important;
    }
    
    .widget-stat-large {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    [data-size="small"],
    [data-size="medium"],
    [data-size="large"],
    [data-size="wide"],
    [data-size="tall"] {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
}

/* Widget Library Modal Adjustments */
.widget-library-item {
    text-align: center;
    padding: 1.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.widget-library-item:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
    transform: translateY(-2px);
}

.widget-library-item i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.widget-library-item span {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ============================================ */
/* Dashboard Widgets System - Enhanced         */
/* ============================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.widget-container {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: default;
}

.widget-container:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: var(--primary);
}

.widget-container.edit-mode {
    border-color: var(--warning);
    border-style: dashed;
    cursor: move;
}

.widget-container.edit-mode:hover {
    background: var(--bg-primary);
}

/* Drag and Drop States */
.widget-container[draggable="true"] {
    cursor: grab;
}

.widget-container[draggable="true"]:active {
    cursor: grabbing;
}

.drag-handle {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.widget-container.edit-mode:hover .drag-handle {
    opacity: 1;
}

.widget-controls {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    gap: 0.35rem;
    z-index: 10;
}

.widget-control-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--danger);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.widget-control-btn.resize-btn {
    background: var(--primary);
}

.widget-control-btn.remove-btn {
    background: var(--danger);
}

.widget-control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.widget-content {
    height: 100%;
}

.widget-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.widget-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.widget-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.widget-stat-large {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.widget-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Tool & Page Widgets */
.tool-widget,
.page-widget {
    transition: all 0.3s ease;
}

.tool-widget:hover,
.page-widget:hover {
    background: var(--bg-primary);
    transform: scale(1.02);
}

/* Size Selector Modal */
.size-option-btn {
    padding: 1.25rem;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.size-option-btn:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.size-preview {
    width: 100%;
    height: 60px;
    background: var(--primary);
    border-radius: 8px;
    opacity: 0.6;
    position: relative;
}

.size-preview[data-preview="small"] {
    width: 50%;
    height: 50px;
}

.size-preview[data-preview="medium"] {
    width: 75%;
    height: 50px;
}

.size-preview[data-preview="large"] {
    width: 100%;
    height: 70px;
}

.size-preview[data-preview="tall"] {
    width: 50%;
    height: 70px;
}

.size-preview[data-preview="wide"] {
    width: 100%;
    height: 45px;
}

.size-option-btn span {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Widget Size Classes */
[data-size="small"] {
    min-height: 160px;
}

[data-size="medium"] {
    min-height: 180px;
}

[data-size="large"] {
    min-height: 280px;
}

[data-size="tall"] {
    min-height: 320px;
}

[data-size="wide"] {
    min-height: 160px;
}

/* Responsive Dashboard */
@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    [data-size="wide"] {
        grid-column: span 3 !important;
    }
    
    [data-size="large"] {
        grid-column: span 3 !important;
    }
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.875rem;
    }
    
    .widget-container {
        padding: 0.875rem;
    }
    
    [data-size="small"] {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
    
    [data-size="medium"] {
        grid-column: span 2 !important;
        grid-row: span 1 !important;
    }
    
    [data-size="large"],
    [data-size="wide"] {
        grid-column: span 2 !important;
        grid-row: span 1 !important;
    }
    
    [data-size="tall"] {
        grid-column: span 1 !important;
        grid-row: span 2 !important;
    }
    
    .widget-stat-large {
        font-size: 1.75rem;
    }
    
    .widget-header h3 {
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .widget-container {
        padding: 0.75rem;
    }
    
    [data-size="small"],
    [data-size="medium"],
    [data-size="large"],
    [data-size="wide"],
    [data-size="tall"] {
        grid-column: span 2 !important;
        grid-row: span 1 !important;
        min-height: 140px !important;
    }
    
    .widget-stat-large {
        font-size: 1.5rem;
    }
    
    .widget-header {
        margin-bottom: 0.5rem;
        padding-bottom: 0.4rem;
    }
    
    .widget-header h3 {
        font-size: 0.85rem;
    }
    
    .widget-controls,
    .drag-handle {
        transform: scale(0.9);
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .widget-container {
        padding: 0.875rem;
    }
    
    [data-size="small"],
    [data-size="medium"],
    [data-size="large"],
    [data-size="wide"],
    [data-size="tall"] {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        min-height: 150px !important;
    }
    
    .widget-stat-large {
        font-size: 1.75rem;
    }
    
    /* Size selector in mobile */
    .size-option-btn {
        padding: 1rem;
    }
    
    .size-preview {
        height: 50px;
    }
}

/* Edit Mode Info Banner */
.edit-mode-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #856404;
}

@media (max-width: 768px) {
    .edit-mode-banner {
        font-size: 0.8rem;
        padding: 0.6rem 0.875rem;
    }
    
    .edit-mode-banner i {
        font-size: 0.85rem;
    }
}

/* Widget Library Categories */
.widget-category {
    margin-bottom: 2rem;
}

.widget-category:last-child {
    margin-bottom: 0;
}

.widget-category h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .widget-category h3 {
        font-size: 1rem;
    }
}

/* Smooth transitions */
.widget-container,
.widget-card,
.widget-body,
.size-option-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Empty state */
#emptyDashboard {
    animation: fadeIn 0.5s ease;
}

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

/* Loading state for widgets */
.widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    color: var(--text-secondary);
}

.widget-loading i {
    animation: spin 1s linear infinite;
}

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

/* Accessibility */
.widget-container:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.widget-control-btn:focus-visible,
.size-option-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Dark theme adjustments */
[data-theme="dark"] .size-option-btn,
[data-theme="amoled"] .size-option-btn {
    background: var(--bg-primary);
}

[data-theme="dark"] .edit-mode-banner,
[data-theme="amoled"] .edit-mode-banner {
    background: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.4);
}

/* ============================================ */
/* Dashboard Widgets - Fix overlap + embed tools */
/* ============================================ */

/* במצב עריכה יש כפתורים בפינות - שלא יעלו על התוכן */
.widget-container.edit-mode .widget-content{
    padding-top: 2.75rem; /* מקום ל-controls + drag */
}

/* שיפור קריאות על כפתורי העריכה */
.widget-controls,
.drag-handle{
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* כפתורים קטנים יותר במובייל כדי שלא יעלו על תוכן */
@media (max-width: 768px){
    .widget-control-btn,
    .drag-handle{
        width: 30px;
        height: 30px;
    }
}

/* Embed tool area */
.widget-embed{
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}

/* Mini Calendar */
.mini-cal-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:.5rem;
}
.mini-cal-title{
    font-weight:800;
    color: var(--primary);
    font-size: .95rem;
    display:flex;
    align-items:center;
    gap:.45rem;
}
.mini-cal-nav{
    display:flex;
    gap:.35rem;
    align-items:center;
}
.mini-cal-btn{
    width:30px;
    height:30px;
    border-radius:10px;
    border:1px solid var(--border);
    background: var(--bg-primary);
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
}
.mini-cal-grid{
    display:grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap:.35rem;
}
.mini-cal-dayname{
    text-align:center;
    font-size:.72rem;
    color: var(--text-secondary);
    padding:.15rem 0;
}
.mini-cal-cell{
    border:1px solid var(--border);
    background: var(--bg-primary);
    border-radius:10px;
    padding:.35rem .2rem;
    min-height: 38px;
    cursor:pointer;
    position:relative;
    overflow:hidden;
}
.mini-cal-cell:hover{
    border-color: var(--primary);
}
.mini-cal-num{
    font-weight:800;
    font-size:.8rem;
    color: var(--text-primary);
    text-align:center;
}
.mini-cal-dot{
    width:6px;height:6px;border-radius:50%;
    background: var(--primary);
    position:absolute;
    bottom:6px;
    left:50%;
    transform:translateX(-50%);
    opacity:.75;
}
.mini-cal-today{
    border-color: var(--primary);
    box-shadow: 0 6px 18px rgba(7,116,126,.15);
}

/* Attendance mini */
.att-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:.5rem;
    padding:.55rem .65rem;
    border:1px solid var(--border);
    background: var(--bg-primary);
    border-radius:12px;
}
.att-row b{ font-weight:800; }
.att-actions{
    display:flex;
    gap:.5rem;
}
.att-pill{
    padding:.35rem .6rem;
    border-radius:999px;
    border:1px solid var(--border);
    background: var(--bg-primary);
    font-size:.8rem;
}


/* ============================================ */
/* AI Side Chat Panel - WhatsApp Style          */
/* ============================================ */

#aiPanelOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: none;
}

#aiSidePanel{
  position: fixed;
  right: 24px;
  bottom: 24px;
  top: auto;

  height: 75vh;          /* ✅ 3/4 מסך */
  max-height: 75vh;

  width: 420px;
  max-width: 92vw;

  background: var(--bg-primary);
  border: 1px solid var(--border);
  box-shadow: 0 18px 60px rgba(0,0,0,0.22);

  border-radius: 18px;

  z-index: 2001;
  transform: translateY(12px) scale(0.92);   /* ✅ “יוצא מהכפתור” */
  opacity: 0;
  transform-origin: bottom right;
  transition: transform 220ms cubic-bezier(.2,.9,.2,1), opacity 220ms ease;

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#aiSidePanel.open{
  transform: translateY(0) scale(1);
  opacity: 1;
}


/* “מגניב” – פס קטן בקצה שמראה שזה Drawer */
#aiSidePanel::before{
  content:"";
  position:absolute;
  left: -10px;
  top: 80px;
  width: 10px;
  height: 68px;
  border-radius: 999px;
  background: rgba(7,116,126,0.25);
  box-shadow: 0 8px 18px rgba(7,116,126,0.20);
}

#aiSidePanel.open{ transform: translateX(0); }

/* Header */
.ai-panel-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(7,116,126,0.14), rgba(7,116,126,0.05));
}

.ai-panel-title{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  color: var(--text-primary);
}

.ai-panel-close{
  width:36px;height:36px;
  border-radius:12px;
  border:1px solid var(--border);
  background: var(--bg-secondary);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 18px;
}

.ai-panel-close:hover{ filter: brightness(0.98); }

/* Quick chips */
.ai-panel-subbar{
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  background: var(--bg-primary);
}
.ai-chip{
  border:1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor:pointer;
  white-space:nowrap;
}
.ai-chip:hover{ filter: brightness(0.98); }

/* Messages area */
.ai-panel-body{
  flex:1;
  overflow-y:auto;
  padding: 14px;
  background: var(--bg-primary);
}

/* IMPORTANT:
   direction:ltr כדי ש”שמאל/ימין” יהיה כמו צ׳אט אמיתי.
   בתוך הבועה נשים direction לפי מי מדבר.
*/
.ai-panel-body{ direction: ltr; }

.ai-msg-row{
  display:flex;
  gap:10px;
  margin: 12px 0;
  align-items:flex-end;
}

.ai-msg-row.user{ justify-content:flex-end; }
.ai-msg-row.bot{ justify-content:flex-start; }

/* Avatar */
.ai-avatar{
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 34px;
  display:flex;
  align-items:center;
  justify-content:center;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.ai-avatar img{
  width:100%;
  height:100%;
  object-fit: cover;
}

.ai-avatar.bot{
  background: linear-gradient(135deg, rgba(7,116,126,0.18), rgba(7,116,126,0.05));
  border: 1px solid rgba(7,116,126,0.25);
  color: var(--primary);
}

/* Bubble */
.ai-bubble{
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.35;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

/* User bubble (right) */
.ai-bubble.user{
  direction: rtl; /* Hebrew typing inside bubble */
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 22px rgba(7,116,126,0.22);
}

/* Bot bubble (left) */
.ai-bubble.bot{
  direction: rtl;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
}

/* Footer */
.ai-panel-footer{
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--bg-primary);
}

.ai-input-wrap{
  display:flex;
  gap:10px;
  align-items:center;
}

#aiSideInput{
  flex:1;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 0 12px;
  outline:none;
  direction: rtl;
}

#aiSideSend{
  width: 48px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color:white;
  cursor:pointer;
  box-shadow: 0 10px 22px rgba(7,116,126,0.25);
}
#aiSideSend:active{ transform: scale(0.98); }

/* Typing indicator */
.ai-typing{
  display:inline-flex;
  gap:5px;
  align-items:center;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}
.ai-dot{
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(7,116,126,0.75);
  animation: aiDotBounce 1.1s infinite ease-in-out;
}
.ai-dot:nth-child(2){ animation-delay: .15s; }
.ai-dot:nth-child(3){ animation-delay: .30s; }
@keyframes aiDotBounce{
  0%,80%,100%{ transform: translateY(0); opacity: .55; }
  40%{ transform: translateY(-5px); opacity: 1; }
}

/* Action buttons under bot message */
.ai-actions{
  margin-top: 8px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  direction: rtl;
}
.ai-action-btn{
  border:1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.ai-action-btn:hover{ filter: brightness(0.98); }

@media (max-width: 768px){
  #aiSidePanel{
    width: 100vw;
    max-width: 100vw;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }
  #aiSidePanel::before{ display:none; }
}

/* ============================================ */
/* AI Mini Views (embedded cards inside chat)   */
/* ============================================ */

.ai-mini-card{
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 14px;
  overflow: hidden;
}

.ai-mini-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(7,116,126,0.12), rgba(7,116,126,0.04));
  border-bottom: 1px solid var(--border);
}

.ai-mini-title{
  font-weight: 800;
  font-size: 0.95rem;
  display:flex;
  align-items:center;
  gap:8px;
}

.ai-mini-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.ai-mini-btn{
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
  cursor: pointer;
}
.ai-mini-btn:hover{ filter: brightness(0.98); }

.ai-mini-body{
  padding: 10px 12px;
  direction: rtl;
}

.ai-mini-kpis{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-kpi{
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 8px 10px;
}
.ai-kpi .k{ font-size: 0.78rem; opacity: 0.8; }
.ai-kpi .v{ font-weight: 900; margin-top: 3px; }

.ai-mini-list{
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.ai-mini-row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding: 8px 10px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.ai-mini-row:last-child{ border-bottom: none; }
.ai-mini-row .l{ opacity: 0.9; }
.ai-mini-row .r{ font-weight: 800; white-space: nowrap; }

.ai-mini-canvas{
  width: 100%;
  max-height: 220px;
  margin-top: 10px;
}

/* ============================================ */
/* Mobile Drawer Menu (Pro)                     */
/* ============================================ */

.mobileMenuOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(3px);
  z-index: 2490;
}

/* Drawer itself */
@media (max-width: 767px){
  #mobileMenu{
    position: fixed !important;
    top: 0;
    right: 0;
    height: 100vh;
    width: 86vw;
    max-width: 360px;

    z-index: 2500;

    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;

    box-shadow: -18px 0 60px rgba(0,0,0,0.22);

    transform: translateX(110%);
    transition: transform 260ms cubic-bezier(.2,.9,.2,1);

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #mobileMenu.open{
    transform: translateX(0);
  }

  /* make sure it displays even if hidden class removed */
  #mobileMenu.hidden{
    display: block !important;
    transform: translateX(110%);
  }
}

/* Fix: enable md:block because .hidden uses !important */
@media (min-width: 768px) {
  .md\:block { display: block !important; }
}

/* ========================================================= */
/* Bundle A - Pro UI Upgrade                                 */
/* ========================================================= */

/* Fix Tailwind responsive classes (because .hidden has !important) */
@media (min-width: 768px) {
  .md\:block { display: block !important; }
  .md\:flex { display: flex !important; }
  .md\:hidden { display: none !important; }
}

/* Sticky header SaaS feel */
#finbotHeader {
  position: sticky;
  top: 0;
  z-index: 120;
  backdrop-filter: blur(8px);
}
#finbotHeader.header-scrolled {
  box-shadow: 0 10px 26px rgba(0,0,0,0.08);
}

/* Mobile Drawer + overlay */
.mobileMenuOverlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(3px);
  z-index: 2490;
}

@media (max-width: 767px){
  #mobileMenu{
    position: fixed !important;
    top: 0;
    right: 0;
    height: 100vh;
    width: 86vw;
    max-width: 360px;
    z-index: 2500;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    box-shadow: -18px 0 60px rgba(0,0,0,0.22);
    transform: translateX(110%);
    transition: transform 260ms cubic-bezier(.2,.9,.2,1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-secondary);
  }
  #mobileMenu.open{ transform: translateX(0); }
}

/* Command Palette */
.cmdpal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  z-index: 5000;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding: 8vh 14px 14px;
}
.cmdpal{
  width: min(720px, 96vw);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.25);
  overflow: hidden;
}
.cmdpal-top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 14px 14px 10px;
}
.cmdpal-title{
  font-weight: 900;
  color: var(--text-primary);
  display:flex;
  align-items:center;
  gap:10px;
}
.cmdpal-hint{
  font-size:.75rem;
  padding:.18rem .55rem;
  border-radius:999px;
  border: 1px solid rgba(7,116,126,.18);
  background: rgba(7,116,126,.08);
  color: var(--primary);
}
.cmdpal-x{
  border:none;
  background: transparent;
  cursor:pointer;
  color: var(--text-secondary);
  font-size: 1rem;
}
.cmdpal-input{
  width: calc(100% - 28px);
  margin: 0 14px 12px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  padding: 0 12px;
  outline: none;
}
.cmdpal-section{
  padding: 0 14px 8px;
  font-size: .78rem;
  color: var(--text-secondary);
}
.cmdpal-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding: 0 14px 14px;
}
.cmdpal-item{
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 14px;
  padding: 12px;
  cursor:pointer;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  text-align:right;
}
.cmdpal-item:hover{
  border-color: rgba(7,116,126,.35);
  box-shadow: 0 10px 22px rgba(7,116,126,.12);
}
.cmdpal-item-title{ font-weight: 900; }
.cmdpal-item-sub{ font-size:.82rem; color: var(--text-secondary); margin-top:2px; }
.cmdpal-item-right{ font-size:.75rem; color: var(--primary); font-weight: 900; }
.cmdpal-empty{
  padding: 18px;
  color: var(--text-secondary);
  text-align:center;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.cmdpal-footer{
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display:flex;
  justify-content:space-between;
  font-size:.78rem;
  color: var(--text-secondary);
}

/* AI Chat panel */
.aichat-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(4px);
  z-index: 4500;
  display:flex;
  align-items:flex-end;
  justify-content:flex-end;
  padding: 14px;
}
.aichat-panel{
  width: min(460px, 96vw);
  height: 75vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 22px 70px rgba(0,0,0,0.25);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.aichat-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
}
.aichat-title{
  display:flex;
  align-items:center;
  gap:10px;
}
.aichat-boticon{
  width: 38px; height: 38px;
  border-radius: 12px;
  background: rgba(7,116,126,.12);
  color: var(--primary);
  display:flex; align-items:center; justify-content:center;
}
.aichat-h1{ font-weight: 900; line-height:1.1; }
.aichat-h2{ font-size:.78rem; color: var(--text-secondary); margin-top:2px; }
.aichat-actions{ display:flex; gap:8px; }
.aichat-iconbtn{
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  cursor:pointer;
}
.aichat-messages{
  flex:1;
  overflow:auto;
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.aichat-row{ display:flex; align-items:flex-end; gap:10px; }
.aichat-row.right{ justify-content:flex-end; }
.aichat-row.left{ justify-content:flex-start; }
.aichat-avatar{
  width: 34px; height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
}
.aichat-avatar.bot{
  background: rgba(7,116,126,.12);
  color: var(--primary);
}
.aichat-bubble{
  max-width: 78%;
  border-radius: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.aichat-bubble.user{
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  border: none;
  border-bottom-right-radius: 6px;
}
.aichat-bubble.bot{
  border-bottom-left-radius: 6px;
}
.aichat-text{
  font-size: .92rem;
  line-height: 1.7;
  word-break: break-word;
}
.aichat-typing{ display:flex; gap:6px; padding: 4px 0; }
.aichat-typing span{
  width: 7px; height: 7px;
  border-radius: 999px;
  background: rgba(7,116,126,.6);
  animation: aitype 1.2s infinite ease-in-out;
}
.aichat-typing span:nth-child(2){ animation-delay: .15s; }
.aichat-typing span:nth-child(3){ animation-delay: .3s; }
@keyframes aitype{
  0%,100%{ transform: translateY(0); opacity:.55; }
  50%{ transform: translateY(-4px); opacity:1; }
}

.aichat-composer{
  border-top: 1px solid var(--border);
  padding: 10px;
  display:flex;
  gap:10px;
  align-items:center;
  background: var(--bg-secondary);
}
.aichat-input{
  flex:1;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  padding: 0 12px;
  outline:none;
}
.aichat-send{
  width: 44px; height: 44px;
  border-radius: 14px;
  border:none;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color:#fff;
  cursor:pointer;
}

/* quick chips + actions */
.aichat-quick{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.aichat-chip{
  border: 1px solid rgba(7,116,126,.22);
  background: rgba(7,116,126,.08);
  color: var(--primary);
  padding: .28rem .65rem;
  border-radius: 999px;
  cursor:pointer;
  font-weight:800;
  font-size:.78rem;
}
.aichat-actionsrow{ display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.aichat-action{
  border: 1px solid var(--border);
  background: var(--bg-primary);
  padding: .38rem .7rem;
  border-radius: 12px;
  cursor:pointer;
  font-weight:800;
  font-size:.82rem;
}

/* mini widgets */
.aichat-widget{
  width: min(360px, 78vw);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 16px;
  padding: 12px;
}
.aichat-widget-title{
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.aichat-kpi{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:10px;
}
.aichat-kpi-card{
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 14px;
  padding: 10px;
}
.aichat-kpi-label{ font-size:.78rem; color: var(--text-secondary); font-weight:800; }
.aichat-kpi-value{ font-size:1.05rem; font-weight: 900; margin-top:2px; color: var(--text-primary); }
.aichat-kpi-sub{ font-size:.75rem; color: var(--text-secondary); margin-top:2px; }

.aichat-chartwrap{
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  background: var(--bg-secondary);
}

/* ============================================ */
/* Responsive Upgrade Pack (Bundle A)           */
/* ============================================ */

/* 1) Better mobile typography + spacing */
@media (max-width: 768px) {
  .rounded-xl { border-radius: 16px; }
  .shadow-md { box-shadow: 0 10px 24px rgba(0,0,0,.08); }
  h2.text-2xl { font-size: 1.35rem; }
  .text-lg { font-size: 1rem; }
}

/* 2) Universal stat grids for modules (instead of inline grids) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* Make big numbers not explode on small screens */
.stat-value.big {
  font-size: 2.25rem;
}
@media (max-width: 480px) {
  .stat-value { font-size: 1.25rem; }
  .stat-value.big { font-size: 1.75rem; }
}

/* 3) Safer tables on mobile */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.table-scroll table th,
.table-scroll table td {
  white-space: nowrap;
}
@media (max-width: 480px) {
  th, td { padding: 0.75rem 0.65rem; font-size: 0.88rem; }
}

/* 4) History buttons row -> stack on mobile */
.history-actions {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
}
.history-actions > button { flex: 1; }
@media (max-width: 768px) {
  .history-actions { flex-direction: column; }
  .history-actions > button { width: 100%; }
}

/* 5) Forecast progress cards - scale down text on phone */
.forecast-progress-value { font-size: 1.5rem; font-weight: 700; }
.forecast-progress-percent { font-size: 1.1rem; margin-top: 0.5rem; }
@media (max-width: 480px) {
  .forecast-progress-value { font-size: 1.15rem; }
  .forecast-progress-percent { font-size: 0.95rem; }
}

/* 6) Dashboard widgets - responsive grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
}

/* Laptop */
@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Tablet */
@media (max-width: 992px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phone */
@media (max-width: 600px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* Widget container look */
.widget-container {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.widget-content {
  padding: 1rem;
}
.widget-container.edit-mode {
  outline: 2px dashed rgba(7,116,126,.35);
  outline-offset: 2px;
}

/* Make "size selector" grid not break on phone */
@media (max-width: 480px) {
  .modal-content {
    width: calc(100% - 24px);
    max-height: 90vh;
  }
}

/* ==============================
   Settings modal - sticky footer
   ============================== */
.modal-content.with-footer{
    display:flex;
    flex-direction:column;
    max-height:min(86vh, 860px);
}
.modal-body-scroll{
    overflow:auto;
    padding-right:2px;
}
.modal-footer-sticky{
    position: sticky;
    bottom: 0;
    display:flex;
    gap:.6rem;
    justify-content: flex-end;
    align-items: center;
    padding: .85rem 1rem;
    background: rgba(255,255,255,.92);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

/* Toolbox toggles (Settings -> ארגז כלים) */
.tool-toggle-grid{
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}
@media (max-width: 640px){
    .tool-toggle-grid{ grid-template-columns: 1fr; }
}
.tool-toggle-item{
    border:1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 14px;
    padding: .85rem .9rem;
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap:.75rem;
}
.tool-toggle-left{display:flex;align-items:center;gap:.7rem;min-width:0;}
.tool-toggle-left i{width:34px;height:34px;border-radius:12px;display:flex;align-items:center;justify-content:center;background:rgba(7,116,126,.12);color:var(--primary);}
.tool-toggle-title{font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.tool-toggle-sub{color:var(--text-secondary);font-size:.82rem;}

    /* sections */
    .settings-section{ margin-bottom: 1.15rem; }
    .settings-section-head{ margin-bottom:.75rem; }
    .settings-section-title{
      display:flex; align-items:center; gap:.6rem;
      font-weight: 1000;
      font-size: 1.15rem;
      color: var(--primary);
    }
    .settings-section-sub{
      margin-top:.25rem;
      color: var(--text-secondary);
      font-weight: 700;
      font-size: .92rem;
      line-height: 1.35;
    }

    .settings-card{
      border-radius: 16px;
      border: 1px solid var(--border);
      background: var(--bg-secondary);
      box-shadow: 0 10px 30px rgba(2,6,23,.06);
    }

    .settings-grid-2{
      display:grid;
      grid-template-columns: repeat(2, minmax(0,1fr));
      gap: 1rem;
    }
    @media (max-width: 720px){
      .settings-grid-2{ grid-template-columns: 1fr; }
    }

    .settings-row{
      display:flex;
      align-items:flex-start;
      justify-content:space-between;
      gap: 1rem;
      flex-wrap:wrap;
    }
    .settings-row-left{ min-width: 220px; flex: 1 1 auto; }
    .settings-row-right{ flex: 0 0 auto; }
    .settings-row-title{ font-weight: 1000; }
    .settings-row-desc{ color: var(--text-secondary); font-size:.9rem; margin-top:.25rem; font-weight:700; }

    .settings-divider{
      height:1px; background: var(--border);
      margin: 1rem 0;
      opacity:.9;
    }

    /* segmented buttons */
    .segmented{
      display:flex;
      gap:.25rem;
      padding:.25rem;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--bg-primary);
      width: fit-content;
    }
    .seg-btn{
      border: none;
      background: transparent;
      padding: .6rem .85rem;
      border-radius: 999px;
      font-weight: 900;
      cursor: pointer;
      color: var(--text-secondary);
      display:flex;
      align-items:center;
      gap:.5rem;
      transition: transform .08s ease, background .12s ease, color .12s ease, box-shadow .12s ease;
      white-space: nowrap;
    }
    .seg-btn:hover{ background: rgba(2,6,23,.04); }
    .seg-btn:active{ transform: scale(.99); }
    .seg-btn.active{
      background: rgba(7,116,126,.12);
      color: var(--primary);
      box-shadow: 0 10px 24px rgba(7,116,126,.10);
    }

    /* uniform expense rows */
    .expense-rows{ display:grid; gap:.45rem; }
    .expense-row{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap: 1rem;
      padding: .65rem .75rem;
      border: 1px solid var(--border);
      border-radius: 14px;
      background: var(--bg-primary);
      min-height: 54px;
    }
    .expense-row-label{
      font-weight: 900;
      overflow:hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 60%;
    }
    .expense-row-input{
      display:flex;
      align-items:center;
      gap:.5rem;
      min-width: 220px;
      justify-content:flex-end;
    }
    @media (max-width: 720px){
      .expense-row{ align-items:flex-start; flex-direction:column; }
      .expense-row-label{ max-width: 100%; white-space: normal; }
      .expense-row-input{ width:100%; min-width: 0; }
    }

    /* info + mini stats */
    .settings-info{
      display:flex;
      gap:.75rem;
      align-items:flex-start;
      padding: .9rem 1rem;
      border: 1px solid var(--border);
      border-radius: 16px;
      background: rgba(7,116,126,.06);
    }
    .settings-info i{ color: var(--primary); margin-top:.15rem; }

    .mini-stat{
      padding:.85rem;
      border-radius: 14px;
      border: 1px solid var(--border);
      background: var(--bg-primary);
    }
    .mini-stat-label{ color: var(--text-secondary); font-size:.85rem; font-weight:800; }
    .mini-stat-value{ font-weight:1000; margin-top:.15rem; }

    .mini-panel{
      padding:.85rem;
      border-radius: 16px;
      border: 1px solid var(--border);
      background: var(--bg-primary);
    }
    .mini-panel-row{
      display:flex; justify-content:space-between; gap:1rem; flex-wrap:wrap;
    }

    .note{
      color: var(--text-secondary);
      font-size:.88rem;
      font-weight:700;
    }

    .btn-pro{
      padding:.65rem 1rem !important;
      border-radius: 14px !important;
      font-weight: 900 !important;
    }
    .color-dot{
      width:32px; height:32px;
      border:2px solid var(--border);
      border-radius: 10px;
      cursor:pointer;
    }

    /* tabs - make them more "SaaS" */
    .settings-tab{
      border: 1px solid var(--border);
      background: var(--bg-primary);
      border-radius: 999px;
      padding: .55rem .85rem;
      font-weight: 900;
      cursor: pointer;
      display:flex;
      align-items:center;
      gap:.5rem;
      transition: transform .08s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
    }
    .settings-tab:hover{ transform: translateY(-1px); }
    .settings-tab.active{
      border-color: rgba(7,116,126,.35);
      background: rgba(7,116,126,.10);
      color: var(--primary);
      box-shadow: 0 12px 28px rgba(7,116,126,.12);
    }