@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* WizeLife smooth-transition base */
html { scroll-behavior: smooth; }
body { transition: background 200ms ease; }

/* ===== CSS Variables ===== */
:root {
    --color-bg-primary: #050507;
    --color-bg-secondary: #0a0a0c;
    --color-bg-card: rgba(255, 255, 255, 0.05);
    --color-border: rgba(255, 255, 255, 0.1);
    --color-text-primary: #ffffff;
    --color-text-secondary: #8892b0;

    /* Category Colors */
    --color-dashboard: #10b981;
    --color-bank: #3b82f6;
    --color-credit: #ef4444;
    --color-stocks: #8b5cf6;
    --color-training: #00d2ff;
    --color-pension: #ff6b6b;
    --color-gemel: #a855f7;
    --color-assets: #f59e0b;
    --color-loans: #ec4899;
    --color-subscriptions: #06b6d4;

    /* Status Colors */
    --color-positive: #00ff88;
    --color-negative: #ff4757;

    /* Spacing */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 30px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

body.light {
    --color-bg-primary: #f8fafc;
    --color-bg-secondary: #ffffff;
    --color-bg-card: rgba(0, 0, 0, 0.03);
    --color-border: rgba(0, 0, 0, 0.1);
    --color-text-primary: #1e293b;
    --color-text-secondary: #64748b;
    --color-positive: #10b981;
    --color-negative: #f43f5e;
}

body.light {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
    color: #1e293b !important;
}

body.light .sidebar {
    background: rgba(255,255,255,0.85) !important;
    border-color: rgba(0,0,0,0.1) !important;
}

body.light .card,
body.light .summary-card {
    background: rgba(255,255,255,0.9) !important;
    border-color: rgba(0,0,0,0.08) !important;
    color: #1e293b !important;
}

body.light .nav-link {
    color: #475569 !important;
}

body.light .nav-link:hover,
body.light .nav-link.active {
    background: rgba(16,185,129,0.1) !important;
    color: #1e293b !important;
}

body.light input, body.light textarea, body.light select {
    background: #ffffff !important;
    border-color: rgba(0,0,0,0.15) !important;
    color: #1e293b !important;
}

body.light .modal-overlay { background: rgba(0,0,0,0.4) !important; }
body.light .modal { background: #ffffff !important; color: #1e293b !important; }

/* ===== iOS Safe Area ===== */
/* top safe area is handled by .mobile-header on mobile, and not needed on desktop */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

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

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);
    min-height: 100vh;
    color: var(--color-text-primary);
    line-height: 1.6;
    /* Pre-reserve 36px for WizeLife HUD bar — eliminates CLS from JS-injected padding */
    padding-top: 36px;
}

/* Pre-paint a dark strip at the top of the viewport BEFORE the JS-injected
   WizeLife HUD bar mounts. Without this the user sees ~1s of empty space
   where the bar will be. Looks identical to the real bar's background. */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(36px + env(safe-area-inset-top));
    background: rgba(5,6,15,0.96);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    z-index: 99998; /* one below the real .wl-bar (99999) so the real bar paints over us once it mounts */
    pointer-events: none;
}

body.ltr {
    direction: ltr;
}

/* ===== Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border-left: 1px solid var(--color-border);
    padding: var(--spacing-lg);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    /* transition gated by body.app-ready so the sidebar doesn't animate from
       its default (visible) position to translateX(100%) on every page load —
       that animation was perceived as 'sidebar opening for a moment then sliding out'. */
}
body.app-ready .sidebar {
    transition: transform var(--transition-normal);
}

body.ltr .sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--color-border);
}

body.ltr .sidebar-header {
    flex-direction: row;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: var(--spacing-xl);
    max-width: 1400px;
    margin-inline-start: max(230px, calc((100vw - 1400px) / 2));
    margin-inline-end: auto;
}

/* ===== Sidebar ===== */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.sidebar-header {
    flex-direction: column;
    align-items: stretch;
}

/* ===== FinSight Brand ===== */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
}

.brand-name {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.brand-highlight {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Language Switcher ===== */
.lang-switcher {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 4px;
    margin-top: 10px;
}

.lang-btn {
    flex: 1;
    padding: 7px 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.5px;
}

.lang-btn:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.06);
}

.lang-btn.active {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin-bottom: var(--spacing-xs);
}

/* RTL: ensure sidebar text reads right-to-left and aligns to the start (right). */
html[dir="rtl"] .sidebar,
body:not(.ltr) .sidebar {
    text-align: right;
    direction: rtl;
}
html[dir="rtl"] .nav-link span:not(.icon),
body:not(.ltr) .nav-link span:not(.icon) {
    text-align: right;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

.nav-link.active {
    background: var(--color-dashboard);
    color: var(--color-bg-primary);
}

.nav-link.active[data-category="bank"] { background: var(--color-bank); }
.nav-link.active[data-category="credit"] { background: var(--color-credit); }
.nav-link.active[data-category="stocks"] { background: var(--color-stocks); }
.nav-link.active[data-category="training"] { background: var(--color-training); }
.nav-link.active[data-category="pension"] { background: var(--color-pension); }
.nav-link.active[data-category="gemel"] { background: var(--color-gemel); }
.nav-link.active[data-category="assets"] { background: var(--color-assets); }
.nav-link.active[data-category="subscriptions"] { background: var(--color-subscriptions); }

.pro-lock {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    margin-right: auto;
    letter-spacing: 0.3px;
    opacity: 0.85;
}

.nav-link .icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.nav-submenu {
    list-style: none;
    margin-right: var(--spacing-xl);
    margin-top: var(--spacing-xs);
}

body.ltr .nav-submenu {
    margin-right: 0;
    margin-left: var(--spacing-xl);
}

.nav-submenu .nav-link {
    font-size: 0.9rem;
    padding: var(--spacing-xs) var(--spacing-md);
}

/* ===== Logo Hero ===== */
/* Hidden — internal pages already show branding via WizeBar (top) + sidebar.
   Kept the rules for reversibility; toggle 'display: block' to restore. */
.logo-hero {
    display: none;
    text-align: center;
    margin-bottom: var(--spacing-sm);
}

.logo-hero-img {
    width: 160px;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
}

/* ===== Auth Buttons ===== */
.auth-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.btn-auth {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-auth:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-dashboard);
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: var(--spacing-xl);
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: var(--spacing-xs);
}

.page-header p {
    color: var(--color-text-secondary);
}

/* ===== Cards ===== */
.card {
    background: var(--color-bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.card-title {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.card-title .icon {
    font-size: 1.4rem;
}

/* ===== Summary Cards Grid ===== */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.summary-card {
    background: var(--color-bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.summary-card .icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
}

.summary-card .label {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-xs);
}

.summary-card .value {
    font-size: clamp(1.2rem, 1.8vw, 2rem);
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Reserve a stable line box so the skeleton→value swap / bold-font load
       does not resize the card (residual CLS mitigation). */
    line-height: 1.5;
    min-height: 1.5em;
}

.summary-card.bank .value { color: var(--color-bank); }
.summary-card.credit .value { color: var(--color-credit); }
.summary-card.stocks .value { color: var(--color-stocks); }
.summary-card.funds .value { color: var(--color-training); }
.summary-card.assets .value { color: var(--color-assets); }
.summary-card.net-worth .value {
    background: linear-gradient(90deg, var(--color-dashboard), #3a7bd5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Net Worth Banner ===== */
.net-worth-banner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
    border: 2px solid var(--color-dashboard);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.net-worth-banner .label {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
}

.net-worth-banner .value {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(90deg, var(--color-dashboard), #3a7bd5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: var(--spacing-md) var(--spacing-sm);
    text-align: right;
    border-bottom: 1px solid var(--color-border);
}

body.ltr th,
body.ltr td {
    text-align: left;
}

th {
    background: var(--color-bg-card);
    color: var(--color-text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

tr:hover {
    background: var(--color-bg-card);
}

.positive { color: var(--color-positive); }
.negative { color: var(--color-negative); }

/* ===== Forms ===== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-dashboard);
}

.form-control::placeholder {
    color: var(--color-text-secondary);
}

select.form-control {
    cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

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

.btn-primary:hover {
    background: #0d9668;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: var(--color-credit);
    color: var(--color-text-primary);
}

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

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.85rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

/* ===== Charts ===== */
.chart-container {
    position: relative;
    height: 300px;
    margin-top: var(--spacing-md);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--spacing-lg);
}

/* Legacy lang-toggle (kept for nav-links pages) */
.lang-toggle, .lang-toggle-header {
    display: none;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl) * 2;
    color: var(--color-text-secondary);
}

.empty-state .icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: var(--spacing-lg);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: var(--color-positive); color: var(--color-bg-primary); }
.badge-danger { background: var(--color-negative); color: var(--color-text-primary); }
.badge-info { background: var(--color-bank); color: var(--color-text-primary); }

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: var(--spacing-xs);
}

/* ===== Mobile Menu Toggle (old FAB - hidden in favor of mobile-header) ===== */
.mobile-menu-toggle {
    display: none;
}

/* ===== Mobile Language Switcher (hidden in favor of mobile-header) ===== */
.mobile-lang-switcher {
    display: none;
}

/* ===== Mobile Header Bar ===== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
    background: rgba(22, 33, 62, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    align-items: center;
    z-index: 150;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    gap: 12px;
}

/* In RTL, the flex row reverses visually so the toggle (first child) ends up
   on the RIGHT — but the user expects the hamburger on the LEFT in Hebrew
   (inline-end in RTL). Reverse the flex direction in RTL so first-child stays
   on the visual LEFT. */
html[dir="rtl"] .mobile-header,
[dir="rtl"] .mobile-header {
    flex-direction: row-reverse;
}

.mobile-header-toggle {
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    flex-shrink: 0;
    /* Inline-start standard: 8px from edge across all WizeLife apps.
       Money's mobile-header uses flex, so position is set on the parent
       container; this explicit hint matches the cross-app convention. */
    margin-inline-start: 0;
    left: 8px;
}

.mobile-header-toggle:hover,
.mobile-header-toggle:active {
    background: var(--color-bg-card);
}

.mobile-header-brand {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    color: var(--color-text-primary);
}

.mobile-header-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
}

.mobile-header-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.mobile-header-lang {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 3px;
    flex-shrink: 0;
}

.mobile-header-lang .lang-btn {
    padding: 5px 8px;
    font-size: 0.72rem;
    border-radius: 6px;
    min-width: 28px;
}

/* ===== Mobile Bottom Tab Bar ===== */
.mobile-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(22, 33, 62, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--color-border);
    z-index: 130;
    align-items: stretch;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.4);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #8892b0;
    padding: 8px 4px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

.tab-item.active {
    color: #00d2ff;
}

.tab-item .tab-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.tab-item .tab-label {
    font-size: 0.62rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ===== Pull-to-Refresh Indicator ===== */
.pull-refresh-indicator {
    position: fixed;
    top: calc(36px + 56px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 120;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    font-size: 1.1rem;
    box-shadow: 0 4px 16px rgba(0, 210, 255, 0.4);
}

.pull-refresh-indicator.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(8px);
}

.pull-refresh-indicator.refreshing {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translateX(-50%) translateY(8px) rotate(360deg); }
}

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
    margin-top: auto;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    html, body {
        overflow-x: clip;
    }

    .sidebar {
        transform: translateX(100%);
        z-index: 200;
        top: 92px;
        height: calc(100vh - 92px);
        overflow-x: hidden;
    }

    body.ltr .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    body.ltr .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .mobile-header {
        display: flex;
        top: calc(36px + env(safe-area-inset-top));
    }

    .main-content {
        margin-right: 0;
        margin-left: 0;
        padding: var(--spacing-md);
        padding-top: calc(36px + 56px + 2*env(safe-area-inset-top, 0px) + var(--spacing-md));
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + var(--spacing-md));
    }

    .mobile-tab-bar {
        display: flex;
    }

    body.ltr .main-content {
        margin-left: 0;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .net-worth-banner {
        padding: var(--spacing-lg);
    }

    .net-worth-banner .value {
        font-size: 2rem;
    }

    .page-header {
        margin-bottom: var(--spacing-md);
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }

    /* Better touch targets */
    .nav-link {
        padding: 12px var(--spacing-md);
        min-height: 44px;
    }

    .btn {
        min-height: 44px;
    }

    /* Tables scroll horizontally on mobile */
    .table-container {
        -webkit-overflow-scrolling: touch;
    }
    /* Tap targets ≥40x40 (a11y / Apple HIG) */
    .lang-btn,[data-lang],[data-wl-lang] {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px 10px;
    }
    .mobile-header-lang .lang-btn {
        min-width: 40px !important;
        min-height: 40px !important;
    }
    button:not(.btn):not(.nav-link):not(.mobile-tab):not(.wbn-btn):not(.bnav-btn):not(.lang-btn) {
        min-height: 40px;
        min-width: 40px;
    }
    /* Small tap targets — WizeMoney specific */
    .mobile-header-brand {
        min-height: 40px;
    }
    .trust-footer-links a {
        min-height: 40px;
        padding: 10px 4px;
        display: inline-flex;
        align-items: center;
    }
}

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

    .summary-card .value {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }

    .modal {
        width: 95%;
        margin: var(--spacing-sm);
    }

    /* Prevent brand wordmark from setting a min-content width wider than the viewport */
    .brand-wordmark {
        font-size: clamp(1.6rem, 9vw, 2.2rem) !important;
    }

    /* Trust strip: prevent overflow at narrow widths */
    .trust-strip {
        font-size: 10px !important;
        white-space: normal;
        padding: 6px 10px !important;
    }
}

/* Extra-narrow screens: further shrink the wordmark */
@media (max-width: 360px) {
    .brand-wordmark {
        font-size: clamp(1.4rem, 8vw, 1.8rem) !important;
    }
}

/* ===== Offline Banner ===== */
.offline-banner {
    display: none;
    position: fixed;
    top: calc(36px + 56px + env(safe-area-inset-top));
    left: 0;
    right: 0;
    z-index: 145;
    background: #374151;
    color: #f3f4f6;
    text-align: center;
    font-size: 0.85rem;
    padding: 8px 16px;
    gap: 8px;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    animation: slideDown 0.3s ease;
}

.offline-banner.visible {
    display: flex;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ===== Skeleton Loading ===== */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position:  400px 0; }
}

.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.06) 25%,
        rgba(255,255,255,0.12) 50%,
        rgba(255,255,255,0.06) 75%
    );
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite linear;
    border-radius: 6px;
    color: transparent !important;
    pointer-events: none;
    user-select: none;
    min-width: 80px;
    display: inline-block;
}

.skeleton::after {
    content: '\00a0'; /* non-breaking space to preserve height */
}

/* ===== Notification Permission Banner ===== */
.notif-prompt {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 210, 255, 0.08);
    border: 1px solid rgba(0, 210, 255, 0.25);
    border-radius: var(--radius-md);
    padding: 12px var(--spacing-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.notif-prompt .notif-prompt-text { flex: 1; }

.notif-prompt .notif-prompt-btns {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

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

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* ===== Stock Alerts Bar ===== */
.alerts-bar {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(239, 68, 68, 0.2) 100%);
    border: 1px solid rgba(245, 158, 11, 0.5);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.alerts-bar-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.alerts-icon {
    font-size: 1.5rem;
    animation: bell-shake 0.5s ease-in-out infinite;
}

@keyframes bell-shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.alerts-count {
    font-weight: bold;
    color: var(--color-assets);
}

.alerts-list {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    flex: 1;
}

.alert-item {
    background: var(--color-bg-card);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.alert-more {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
}

/* ===== Dashboard Budget Alerts ===== */
#dashboardBudgetAlerts {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
#dashboardBudgetAlerts.has-alerts {
    display: flex;
}
.dash-budget-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    border: 1px solid transparent;
}
.dash-budget-alert.warning {
    background: rgba(234, 179, 8, 0.12);
    border-color: rgba(234, 179, 8, 0.4);
}
.dash-budget-alert.danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
}
.dash-budget-alert .alert-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.6;
    flex-shrink: 0;
}
.dash-budget-alert .alert-dismiss:hover { opacity: 1; }

/* ===== MA150 Indicators ===== */
.ma150-na {
    color: var(--color-text-secondary);
}

.ma150-above {
    color: var(--color-positive);
}

.ma150-below {
    color: var(--color-negative);
}

/* ===== Alert Rows ===== */
.alert-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
}

.alert-row.triggered {
    border-color: var(--color-positive);
    background: rgba(0, 255, 136, 0.1);
}

.alert-row.disabled {
    opacity: 0.5;
}

.alert-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.alert-type {
    font-weight: 500;
}

.alert-value {
    color: var(--color-text-secondary);
    font-family: monospace;
}

.alert-actions {
    display: flex;
    gap: var(--spacing-xs);
}

/* ===== Search Results ===== */
.search-results {
    margin-top: var(--spacing-sm);
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-stocks);
}

.result-symbol {
    font-weight: bold;
    font-family: monospace;
    color: var(--color-stocks);
    min-width: 70px;
}

.result-name {
    flex: 1;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-market {
    font-size: 1.1rem;
}

.search-loading,
.search-empty,
.search-error {
    padding: var(--spacing-md);
    text-align: center;
    color: var(--color-text-secondary);
}

.search-error {
    color: var(--color-negative);
}

/* ===== Spin Animation ===== */
.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* ===== Print Styles ===== */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .btn,
    .modal-overlay {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    body {
        background: white;
        color: black;
        padding-top: 0 !important;
    }

    .card {
        border: 1px solid #ddd;
        background: white;
    }
}

/* ===== Tooltip ===== */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 50%;
    transform: translateX(50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 12px;
    line-height: 1.5;
    padding: 7px 11px;
    border-radius: 8px;
    white-space: pre-wrap;
    max-width: 240px;
    text-align: right;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
    opacity: 1;
}
.tooltip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-bg-card);
    color: var(--color-text-secondary);
    font-size: 11px;
    cursor: help;
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 4px;
}


/* ── WizeLife Design System ── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800;900&family=Inter:wght@400;500;600;700&display=swap');

h1, h2, h3, h4, .sidebar-header h1, .page-title, .card-title, .stat-label, .nav-item span {
    font-family: 'Plus Jakarta Sans', sans-serif;
    letter-spacing: -0.3px;
}

body {
    background: var(--color-bg-primary) !important;
}

/* Sidebar refinement */
.sidebar {
    background: #060810;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.nav-item {
    border-radius: 10px;
    transition: all 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.03);
}

.nav-item.active {
    background: rgba(16,185,129,0.1);
    color: #10b981;
}

/* Card refinement */
.card, .stat-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
}

.stat-value {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Buttons — primary uses money green gradient */
.btn-primary, button.primary {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
}

/* Tables */
table th {
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-size: 10.5px;
    color: #6b7280;
    font-weight: 600;
}


/* ── WizeMoney sidebar SVG enhancement ── */
.sidebar .nav-link .icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .nav-link .icon svg { width: 16px; height: 16px; opacity: .8; transition: opacity .15s; }
.sidebar .nav-link:hover .icon svg { opacity: 1; }
.sidebar .nav-link.active .icon svg { opacity: 1; color: var(--color-dashboard, #10b981); }

/* Brand wordmark — gradient like web-apps.html */
.sidebar .brand-name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; letter-spacing: -0.3px; }
.sidebar .brand-highlight {
    background: linear-gradient(135deg, #10b981, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Nav menu typography */
.sidebar .nav-link { font-family: 'Inter', -apple-system, sans-serif; font-size: 13px; font-weight: 500; }
.sidebar .nav-link.active { font-weight: 700; }


/* ── WizeLife — page polish (matches web-apps.html design language) ── */
/* Cards across all 38 pages */
.card, .data-card, .info-card {
    border-radius: 14px !important;
    border: 1px solid rgba(255,255,255,0.07) !important;
    background: rgba(255,255,255,0.03) !important;
}

/* Stat values use Plus Jakarta Sans + tabular numerics */
.stat-num, .stat-value, .metric-value, .big-num {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-weight: 800 !important;
    letter-spacing: -0.5px !important;
    font-variant-numeric: tabular-nums !important;
}

/* Stat labels uppercase + spaced */
.stat-label, .metric-label {
    font-size: 10px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
    color: var(--color-text-secondary, #6b7280) !important;
    font-family: 'Inter', sans-serif !important;
}

/* Tables — header styling */
table th {
    font-size: 10.5px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.7px !important;
    color: #6b7280 !important;
}

/* Section headers (h2/h3) use Plus Jakarta Sans */
.page-content h1, .page-content h2, .page-content h3,
.dashboard h1, .dashboard h2, .dashboard h3 {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    letter-spacing: -0.4px !important;
}

/* Money values (numbers in ₪/$) — JetBrains Mono */
.money-value, .price, .amount, td.numeric, .total-value {
    font-family: 'JetBrains Mono', ui-monospace, monospace !important;
    font-variant-numeric: tabular-nums !important;
}

/* Buttons — primary uses money green gradient */
.btn-primary, button[type="submit"]:not(.cancel):not(.close) {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-weight: 700 !important;
    letter-spacing: -0.2px !important;
}

/* Badges */
.badge, .pill, .chip {
    font-family: 'Inter', sans-serif !important;
    font-size: 10.5px !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px !important;
}


/* ── WizeMoney right panel + sidebar light/dark themes ── */
.wl-rpanel-themed {
    background: #060810;
    border-right: 1px solid rgba(255,255,255,0.07);
    color: #eef2ff;
}
body.light .wl-rpanel-themed {
    background: #ffffff;
    border-right: 1px solid rgba(0,0,0,0.08);
    color: #1e293b;
    box-shadow: 2px 0 12px rgba(0,0,0,0.04);
}
.wl-rpanel-themed > div {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.07);
}
body.light .wl-rpanel-themed > div {
    background: #f8fafc !important;
    border-color: rgba(0,0,0,0.08) !important;
}
body.light .wl-rpanel-themed div[style*="color:#94a3b8"],
body.light .wl-rpanel-themed div[style*="color: #94a3b8"] {
    color: #475569 !important;
}
body.light .wl-rpanel-themed div[style*="color:#eef2ff"] {
    color: #1e293b !important;
}
body.light .wl-rpanel-themed div[style*="color:rgba(255,255,255,0.3)"] {
    color: rgba(0,0,0,0.4) !important;
}
body.light .wl-rpanel-themed a[href*="wize-ai"] {
    background: rgba(99,102,241,0.06) !important;
}

/* Sidebar light mode */
body.light .sidebar {
    background: #ffffff !important;
    border-color: rgba(0,0,0,0.08) !important;
}
body.light .sidebar .nav-link {
    color: #475569 !important;
}
body.light .sidebar .nav-link:hover {
    background: rgba(0,0,0,0.04) !important;
    color: #1e293b !important;
}
body.light .sidebar .nav-link.active {
    background: rgba(16,185,129,0.1) !important;
    color: #10b981 !important;
}
body.light .sidebar .nav-link .icon svg {
    color: #475569;
}
body.light .sidebar-footer {
    border-color: rgba(0,0,0,0.08) !important;
}

/* Re-open tab in light mode */
body.light #wl-rp-reopen {
    background: rgba(99,102,241,0.1) !important;
    color: #6366f1 !important;
}

/* ── WizeLife unified theme toggle (cross-app consistency) ── */
.wl-theme-btn,
#wl-theme-toggle,
#wlThemeToggle {
  position: fixed !important;
  bottom: 18px !important; left: 18px !important;
  width: 38px !important; height: 38px !important;
  border-radius: 50% !important;
  background: rgba(15,23,42,0.85) !important;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12) !important;
  color: #cbd5e1 !important;
  font-size: 15px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25) !important;
  z-index: 9999 !important;
  transition: all .18s ease !important;
}
.wl-theme-btn:hover,
#wl-theme-toggle:hover,
#wlThemeToggle:hover {
  transform: translateY(-2px) scale(1.05) !important;
  border-color: rgba(255,255,255,0.25) !important;
}
@media (max-width: 820px) {
  /* On mobile the hamburger drawer already provides theme + language switching.
     Hide the floating duplicates — they overlapped content and weren't reliably
     tappable. Users get theme + language from the ☰ menu instead. */
  .wl-theme-btn,
  #wl-theme-toggle,
  #wlThemeToggle,
  #globalLangSwitcher {
    display: none !important;
  }
}
[data-theme="light"] .wl-theme-btn,
[data-theme="light"] #wl-theme-toggle,
body.light .wl-theme-btn,
body.light #wlThemeToggle {
  background: rgba(255,255,255,0.95) !important;
  border-color: rgba(0,0,0,0.1) !important;
  color: #475569 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08) !important;
}


/* Comprehensive WizeMoney light mode (covers all inline-style sidebars/panels) */
body.light #wl-bar {
    background: rgba(255,255,255,0.95) !important;
    border-bottom-color: rgba(0,0,0,0.08) !important;
}
body.light #wl-bar a, body.light #wl-bar span {
    color: #1e293b !important;
}
body.light #wl-bar a[style*="color:#7b88ad"] {
    color: #475569 !important;
}

/* Right panel cards inner */
body.light .wl-rpanel-themed > div {
    background: #ffffff !important;
    border-color: rgba(0,0,0,0.08) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
body.light .wl-rpanel-themed div[style*="color:#94a3b8"] {
    color: #475569 !important;
}
body.light .wl-rpanel-themed div[style*="rgba(255,255,255,0.04)"] {
    border-color: rgba(0,0,0,0.05) !important;
}

/* Reopen tab in light */
body.light #wl-rp-reopen {
    background: rgba(99,102,241,0.1) !important;
    color: #6366f1 !important;
    border-color: rgba(99,102,241,0.2) !important;
}

/* Theme toggle works in both modes — already handled */

/* Body root in light */
body.light {
    background: #f8fafc !important;
    color: #1e293b !important;
}

/* Mobile bottom nav in light (FinSight some pages) */
body.light nav.fixed[style*="rgba(15,23,42"] {
    background: rgba(255,255,255,0.97) !important;
    border-top-color: rgba(0,0,0,0.08) !important;
}


/* FinSight — active items in light mode */
body.light .nav-link.active,
body.light .tab.active,
body.light .filter-chip.active,
body.light .fund-type-tab.active {
    background: rgba(16,185,129,0.1) !important;
    color: #10b981 !important;
}
body.light .nav-link.active .icon {
    color: #10b981 !important;
}


/* FinSight — onboarding overlay light mode */
body.light #onboardingOverlay.active {
    background: rgba(248,250,252,0.98) !important;
}
body.light #onboardingBox {
    background: #ffffff !important;
    color: #1e293b !important;
}
body.light #onboardingBox h2,
body.light #onboardingBox .ob-subtitle {
    color: #1e293b !important;
}
body.light .ob-step {
    background: #f8fafc !important;
    border-color: rgba(0,0,0,0.08) !important;
    color: #1e293b !important;
}


/* Collapsible nav groups */
.nav-group .nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.nav-group.open .nav-submenu {
    max-height: 800px;
}
.nav-group .nav-chevron {
    transition: transform 0.2s ease;
    display: inline-block;
}
.nav-group.open .nav-chevron {
    transform: rotate(180deg);
}
.nav-group-toggle {
    display: flex !important;
    align-items: center !important;
    gap: 9px !important;
    user-select: none;
}

/* ─── LTR layout normalization ────────────────────────────────────────────
   When language is English/Portuguese/Spanish, document.documentElement.dir
   becomes 'ltr'. Most layout reads top-to-bottom-left-to-right; we override
   the few rules that hard-code text-align:right (RTL-default) so body
   content aligns to the LEFT, but page titles (h1/h2) stay CENTERED for
   visual hierarchy.
   ─────────────────────────────────────────────────────────────────────── */
html[dir="ltr"] body,
html[dir="ltr"] .main-content,
html[dir="ltr"] .main-content p,
html[dir="ltr"] .main-content div:not(.text-center):not([class*="text-center"]),
html[dir="ltr"] .main-content section,
html[dir="ltr"] .main-content label,
html[dir="ltr"] .main-content li,
html[dir="ltr"] .card,
html[dir="ltr"] .info-row,
html[dir="ltr"] .modal-body,
html[dir="ltr"] .modal-content,
html[dir="ltr"] table,
html[dir="ltr"] td,
html[dir="ltr"] th {
    text-align: left;
}

/* Page titles stay centered in LTR */
html[dir="ltr"] .main-content > h1,
html[dir="ltr"] .main-content > h2,
html[dir="ltr"] .page-title,
html[dir="ltr"] h1.page-title,
html[dir="ltr"] h2.page-title,
html[dir="ltr"] .page-header h1,
html[dir="ltr"] .page-header h2,
html[dir="ltr"] .section-header,
html[dir="ltr"] .modal-title {
    text-align: center;
}

/* Sidebar should also read left-to-right in LTR (override the RTL block above) */
html[dir="ltr"] .sidebar,
html[dir="ltr"] .nav-link span:not(.icon) {
    text-align: left;
    direction: ltr;
}

/* LTR: fix form elements that may have hardcoded direction:rtl in page styles */
html[dir="ltr"] input,
html[dir="ltr"] select,
html[dir="ltr"] textarea {
    direction: ltr;
    text-align: left;
}

/* LTR: fix spans and inline content that inherit RTL */
html[dir="ltr"] .main-content span:not(.icon):not(.emoji),
html[dir="ltr"] .main-content strong,
html[dir="ltr"] .main-content small {
    text-align: left;
}

/* ===== Page transitions (View Transitions API) ===== */
@keyframes vt-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes vt-fade-out { from { opacity: 1; } to { opacity: 0; } }

::view-transition-old(root) {
    animation: 120ms ease-out both vt-fade-out;
}
::view-transition-new(root) {
    animation: 150ms ease-in  both vt-fade-in;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) { animation: none; }
}
