/* ========================================= */
/* БАЗОВЫЕ НАСТРОЙКИ                         */
/* ========================================= */
:root {
    --bg-light: #E5E5EA;    
    --card-light: #F2F2F7;  
    --porcelain: #FFFFFF;   
    --text-main: #1C1C1E;   
    --text-muted: #8E8E93;  
    --neon-green: #34C759;  
    --neon-blue: #0A84FF;
    --alert-orange: #FF9F0A;
    --alert-red: #FF453A;
    --app-width: 480px; 
}

* { 
    margin: 0; padding: 0; box-sizing: border-box; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    -webkit-tap-highlight-color: transparent; 
}

html {
    background-color: var(--bg-light);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden; 
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    width: 100%;
    height: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: 0; 
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0;
}

.screen { 
    display: none; 
    flex: 1; 
    width: 100%; 
    max-width: var(--app-width);
    margin: 0 auto; 
    background: var(--bg-light); 
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.15); 
    overflow: hidden; 
}

.screen.active { display: block; }

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

/* ========================================= */
/* ЭКРАН АВТОРИЗАЦИИ                         */
/* ========================================= */
#login-screen { background: var(--bg-light); }
#login-screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

.login-card { 
    width: 90%; max-width: 340px; 
    background: rgba(255, 255, 255, 0.7); 
    backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); 
    padding: 40px 30px; border-radius: 32px; 
    box-shadow: 0 15px 35px rgba(0,0,0,0.05); 
    border: 1px solid rgba(255, 255, 255, 0.8); 
    display: flex; flex-direction: column; gap: 15px; text-align: center;
}

.login-card .subtitle { font-size: 20px; font-weight: 700; color: var(--text-main); margin-bottom: 10px;}

.input-group { position: relative; width: 100%; }
.input-group input { 
    width: 100%; background: rgba(0,0,0,0.04); 
    border: 1px solid rgba(0,0,0,0.05); padding: 15px 20px; 
    border-radius: 16px; font-size: 16px; color: var(--text-main); 
    outline: none; transition: 0.2s;
}
.input-group input:focus { background: rgba(0,0,0,0.02); border-color: var(--neon-blue); }

.password-group .toggle-password { 
    position: absolute; right: 15px; top: 50%; transform: translateY(-50%); 
    background: none; border: none; color: var(--text-muted); 
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}

#login-btn { 
    width: 100%; background: var(--text-main); color: #fff; 
    border: none; padding: 16px; border-radius: 16px; font-size: 16px; 
    font-weight: 700; cursor: pointer; transition: 0.2s; margin-top: 10px;
}
#login-btn:active { transform: scale(0.96); }

.error-text { color: var(--alert-red); font-size: 13px; font-weight: 500; height: 15px; }

/* ========================================= */
/* СТРУКТУРА ПРИЛОЖЕНИЯ                      */
/* ========================================= */
.mobile-header { display: none !important; }

.app-wrapper { display: flex; flex-direction: column; height: 100%; width: 100%; }

#main-content { flex: 1; position: relative; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#main-content > div:not(.view-dashboard) { padding-bottom: 120px; }

.view-dashboard { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-light); overflow: hidden; }

#btn-privacy-toggle { 
    position: absolute; top: 15px; right: 20px; width: 40px; height: 40px; 
    background: rgba(255,255,255,0.8); backdrop-filter: blur(10px); 
    border-radius: 20px; border: 1px solid rgba(0,0,0,0.05); cursor: pointer; 
    z-index: 9999; display: flex; align-items: center; justify-content: center; 
    color: var(--text-main); box-shadow: 0 2px 10px rgba(0,0,0,0.05); transition: transform 0.2s;
}
#btn-privacy-toggle:active { transform: scale(0.9); }
#btn-privacy-toggle svg { width: 20px; height: 20px; transition: 0.3s; }
#btn-privacy-toggle .icon-eye-slash { display: none; }
body.privacy-mode #btn-privacy-toggle .icon-eye { display: none; }
body.privacy-mode #btn-privacy-toggle .icon-eye-slash { display: block; color: var(--text-muted); }

.view-dashboard .num { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.view-dashboard .cents { font-size: 0.75em; opacity: 0.6; font-weight: 500; }
.view-dashboard .currency-symbol { font-size: 0.8em; color: var(--text-muted); font-weight: 500; }
.view-dashboard .sensitive-amount { transition: filter 0.3s ease, opacity 0.3s ease; }
body.privacy-mode .view-dashboard .sensitive-amount { filter: blur(8px); opacity: 0.4; user-select: none; pointer-events: none; }

/* ========================================= */
/* НИЖНИЙ НАВ-БАР (FLOATING PILL - ПРИБИТЫЙ) */
/* ========================================= */
#sidebar {
    position: absolute !important;
    bottom: calc(15px + env(safe-area-inset-bottom)) !important; /* Железобетонный отступ */
    left: 50% !important;
    transform: translateX(-50%) translateY(0) !important;
    width: auto !important;
    padding: 0 15px !important;
    height: 60px !important;
    border-radius: 30px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(25px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(200%) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1) !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 9999 !important;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s ease !important;
}

body.card-opened #sidebar { transform: translateX(-50%) translateY(150px) !important; opacity: 0 !important; pointer-events: none !important; }
.sidebar-header { display: none !important; }

.nav-links { display: flex; flex-direction: row; gap: 5px; align-items: center; padding: 0; margin: 0; list-style: none;}
.nav-links li { padding: 0; display: flex; justify-content: center; align-items: center; cursor: pointer;}
.icon-box-3d { width: 50px; height: 50px; border-radius: 25px; background: transparent; display: flex; align-items: center; justify-content: center; transition: 0.3s; color: var(--text-main); opacity: 0.5; }
.icon-box-3d svg { width: 24px; height: 24px; transition: 0.3s; }
.nav-links li.active .icon-box-3d { opacity: 1; color: var(--neon-blue); }





/* ========================================= */
/* WALLET STACK И КАРТЫ                      */
/* ========================================= */
.wallet-stack {
    position: absolute; top: 0; left: 0; right: 0;
    bottom: calc(-1 * env(safe-area-inset-bottom) - 50px);
    overflow: hidden; z-index: 10;
}

.w-card {
    position: absolute; top: 0; left: 2%; width: 96%; height: 100%; 
    background: var(--card-light); border-radius: 28px 28px 0 0;
    box-shadow: 0 -8px 25px rgba(0,0,0,0.06), 0 5px 15px rgba(0,0,0,0.02);
    transform-origin: top center; transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1), filter 0.5s ease;
    display: flex; flex-direction: column; overflow: hidden;
    color: var(--text-main); border: 1px solid rgba(0,0,0,0.04);
}

.card-0 { z-index: 1; cursor: pointer; border: none; box-shadow: none; background: transparent;}
.bg-capsules-container { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; display: flex; justify-content: center;}
.card-1 { z-index: 3; }
.card-2 { z-index: 4; }
.card-3 { z-index: 5; }

.w-card-header { 
    height: 75px; display: flex; justify-content: space-between; align-items: center; 
    padding: 0 25px; font-size: 18px; font-weight: 700; color: var(--text-main); 
    cursor: pointer; background: rgba(242, 242, 247, 0.98); 
    backdrop-filter: blur(20px); z-index: 10; border-bottom: 1px solid rgba(0,0,0,0.03); flex-shrink: 0;
}
.header-left { display: flex; align-items: center; }

.w-card-content {
    padding: 25px 20px calc(300px + env(safe-area-inset-bottom)) 20px;
    flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; background: var(--card-light);
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease; cursor: default;
}
.w-card-content::-webkit-scrollbar { display: none; }

.wallet-stack[data-active-card="1"] .card-1 .w-card-content, 
.wallet-stack[data-active-card="2"] .card-2 .w-card-content, 
.wallet-stack[data-active-card="3"] .card-3 .w-card-content { opacity: 1; visibility: visible; transition-delay: 0.2s; }

.wallet-stack[data-active-card="0"] .card-0 { transform: translateY(0); filter: brightness(1); }
.wallet-stack[data-active-card="0"] .card-1 { transform: translateY(calc(100dvh - 360px - env(safe-area-inset-bottom))); filter: brightness(1); }
.wallet-stack[data-active-card="0"] .card-2 { transform: translateY(calc(100dvh - 280px - env(safe-area-inset-bottom))); filter: brightness(1); }
.wallet-stack[data-active-card="0"] .card-3 { transform: translateY(calc(100dvh - 200px - env(safe-area-inset-bottom))); filter: brightness(1); }

.wallet-stack[data-active-card="1"] .card-0 { transform: translateY(-100px); }
.wallet-stack[data-active-card="1"] .card-1 { transform: translateY(0); }
.wallet-stack[data-active-card="1"] .card-2 { transform: translateY(calc(100dvh - 170px - env(safe-area-inset-bottom))); } 
.wallet-stack[data-active-card="1"] .card-3 { transform: translateY(calc(100dvh - 95px - env(safe-area-inset-bottom))); }  

.wallet-stack[data-active-card="2"] .card-0 { transform: translateY(-100px); }
.wallet-stack[data-active-card="2"] .card-1 { transform: translateY(0); filter: brightness(0.85); } 
.wallet-stack[data-active-card="2"] .card-2 { transform: translateY(75px); } 
.wallet-stack[data-active-card="2"] .card-3 { transform: translateY(calc(100dvh - 95px - env(safe-area-inset-bottom))); } 

.wallet-stack[data-active-card="3"] .card-0 { transform: translateY(-100px); }
.wallet-stack[data-active-card="3"] .card-1 { transform: translateY(0); filter: brightness(0.7); } 
.wallet-stack[data-active-card="3"] .card-2 { transform: translateY(75px); filter: brightness(0.85); } 
.wallet-stack[data-active-card="3"] .card-3 { transform: translateY(150px); } 

/* ========================================= */
/* AMBIENT MESH GRADIENT                     */
/* ========================================= */
.ambient-bg { width: 100%; height: 100%; background: #F2F2F7; position: relative; overflow: hidden; }
.ambient-orb-1 { position: absolute; width: 300px; height: 300px; border-radius: 50%; background: rgba(10, 132, 255, 0.15); top: -50px; left: -50px; filter: blur(60px); animation: orbFloat1 15s infinite alternate ease-in-out; }
.ambient-orb-2 { position: absolute; width: 350px; height: 350px; border-radius: 50%; background: rgba(52, 199, 89, 0.15); bottom: 100px; right: -80px; filter: blur(60px); animation: orbFloat2 18s infinite alternate ease-in-out; }
.ambient-orb-3 { position: absolute; width: 250px; height: 250px; border-radius: 50%; background: rgba(255, 159, 10, 0.12); top: 40%; left: 40%; filter: blur(60px); animation: orbFloat3 20s infinite alternate ease-in-out; }
@keyframes orbFloat1 { 100% { transform: translate(50px, 30px) scale(1.1); } }
@keyframes orbFloat2 { 100% { transform: translate(-40px, -50px) scale(1.2); } }
@keyframes orbFloat3 { 100% { transform: translate(-30px, 40px) scale(1.1); } }

/* ========================================= */
/* PORCELAIN UI И BENTO GRID                 */
/* ========================================= */
.hero-value { font-size: clamp(38px, 9vw, 54px); font-weight: 800; color: var(--text-main); line-height: 1.1; letter-spacing: -1px; text-align: center; pointer-events: none;}
.bento-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; }
.bento-item { background: var(--porcelain); border-radius: 20px; padding: 18px; border: 1px solid rgba(0,0,0,0.02); display: flex; flex-direction: column; justify-content: space-between; height: 130px; box-shadow: 0 6px 20px rgba(0,0,0,0.04); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.bento-item.full-width { grid-column: span 2; height: auto; min-height: 115px; }
.bento-item.interactive { cursor: pointer; }
.bento-item.interactive:active { transform: scale(0.96); box-shadow: 0 1px 5px rgba(0,0,0,0.02); }
.bento-top { display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.bento-icon-3d { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; overflow: hidden; background: transparent; mix-blend-mode: multiply; }
.bento-icon-3d img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.1); }
.bento-arrow { color: #C7C7CC; font-size: 22px; font-weight: 400; line-height: 1; }
.bento-pct { font-size: 16px; font-weight: 700; color: var(--text-main); pointer-events: none; }
.bento-name { font-size: 13px; color: var(--text-muted); margin-top: auto; margin-bottom: 4px; font-weight: 500; pointer-events: none;}
.bento-val { font-size: clamp(16px, 4vw, 18px); font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;}
.bento-item.full-width .bento-val { font-size: clamp(24px, 6vw, 28px); margin-top: 2px;}

/* ========================================= */
/* TOOLTIPS / POPOVERS                       */
/* ========================================= */
.badge-wrapper { position: relative; display: inline-flex; align-items: center; cursor: pointer; pointer-events: auto; }
.badge-ui { padding: 4px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 4px; transition: transform 0.15s ease; }
.badge-wrapper:active .badge-ui { transform: scale(0.95); }
.badge-popover { 
    position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(10px) scale(0.95); 
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); 
    border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 14px; padding: 14px; min-width: 180px; color: var(--text-main); 
    box-shadow: 0 15px 35px rgba(0,0,0,0.1); opacity: 0; visibility: hidden; pointer-events: none; 
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); z-index: 1000; display: flex; flex-direction: column; gap: 8px; 
}
.badge-popover.active { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0) scale(1); pointer-events: auto; }
.badge-popover::after { 
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); 
    border-width: 7px; border-style: solid; border-color: rgba(255, 255, 255, 0.85) transparent transparent transparent; 
}
.badge-popover.popover-down { bottom: auto; top: calc(100% + 10px); transform: translateX(-50%) translateY(-10px) scale(0.95); }
.badge-popover.popover-down.active { transform: translateX(-50%) translateY(0) scale(1); }
.badge-popover.popover-down::after { top: auto; bottom: 100%; border-color: transparent transparent rgba(255, 255, 255, 0.85) transparent; }

.bp-row { display: flex; justify-content: space-between; font-size: 13px; align-items: center; }
.bp-label { color: var(--text-muted); font-weight: 500;}
.bp-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.bp-divider { height: 1px; background: rgba(0,0,0,0.05); margin: 2px 0; }

/* ========================================= */
/* ОРБИТАЛЬНЫЕ КАПСУЛЫ                       */
/* ========================================= */
.bg-capsule { 
    background: rgba(255, 255, 255, 0.7); 
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); 
    border: 1px solid rgba(255, 255, 255, 0.9); 
    border-radius: 20px; 
    padding: 10px 14px; 
    color: var(--text-main); 
    display: flex; flex-direction: column; align-items: center; 
    box-shadow: 0 10px 32px rgba(0,0,0,0.1); 
    white-space: nowrap;        
    min-width: max-content;     
}
.bg-capsule .cap-date { 
    font-size: 10px; 
    color: var(--neon-blue); 
    background: rgba(10, 132, 255, 0.1);
    padding: 3px 6px;
    border-radius: 6px;
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    font-weight: 700; 
    margin-bottom: 4px; 
    white-space: nowrap;        
}
.bg-capsule .cap-val { font-size: 14px; font-weight: 800; white-space: nowrap; }
.bg-capsule .cap-pct { font-size: 11px; font-weight: 600; margin-top: 1px; }
.orbit-system { position: absolute; top: 175px; left: 50%; width: 0; height: 0; z-index: 2; }
.orb-center { 
    position: absolute; top: 0; left: 0; transform: translate(-50%, -50%) scale(1.15); 
    z-index: 5; border-color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.85); 
    box-shadow: 0 10px 40px rgba(0,0,0,0.12), inset 0 0 20px rgba(255,255,255,0.8); 
    animation: centerFloat 6s ease-in-out infinite alternate; 
}
@keyframes centerFloat { 
    0% { transform: translate(-50%, -50%) scale(1.15) translateY(0); } 
    100% { transform: translate(-50%, -50%) scale(1.15) translateY(-10px); } 
}
.orb-track { position: absolute; top: 0; left: 0; width: 0; height: 0; animation: spinOrbit 40s linear infinite; }
@keyframes spinOrbit { 100% { transform: rotate(360deg); } }
.orb-satellite { position: absolute; top: -120px; left: 0; width: 0; height: 0; animation: counterSpin 40s linear infinite; }
@keyframes counterSpin { 100% { transform: rotate(-360deg); } }
.orb-levitate { position: absolute; top: 0; left: 0; transform: translate(-50%, -50%); opacity: 0.9; animation: satFloat 4s ease-in-out infinite alternate; }
@keyframes satFloat { 
    0% { transform: translate(-50%, -50%) translateY(0); } 
    100% { transform: translate(-50%, -50%) translateY(-10px); } 
}

/* ========================================= */
/* МОДАЛЬНЫЕ ОКНА И ТАЙМЛАЙН                 */
/* ========================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.2); z-index: 99999; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s; padding: 20px;}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content { background: rgba(242, 242, 247, 0.85); backdrop-filter: blur(25px) saturate(150%); -webkit-backdrop-filter: blur(25px) saturate(150%); border: 1px solid rgba(255, 255, 255, 0.5); width: 100%; max-width: var(--app-width); border-radius: 32px; padding: 25px 20px; transform: translateY(30px) scale(0.95); opacity: 0; transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s; max-height: 85vh; display: flex; flex-direction: column; color: var(--text-main); box-shadow: 0 20px 50px rgba(0,0,0,0.1); }
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); opacity: 1; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding-bottom: 15px; border-bottom: 1px solid rgba(0,0,0,0.05);}
.modal-title { font-size: 20px; font-weight: 700; color: var(--text-main);}
.modal-close { background: rgba(0,0,0,0.05); width: 30px; height: 30px; border-radius: 15px; color: #8E8E93; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; border: none;}
.modal-close:active { transform: scale(0.9); background: rgba(0,0,0,0.1); }
.modal-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; padding-right: 5px; scrollbar-width: none;}
.modal-list::-webkit-scrollbar { display: none; }

.accordion-item { background: transparent; box-shadow: none; border: none; position: relative; margin-bottom: 0; padding: 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.accordion-item:last-child { border-bottom: none; }
.accordion-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 14px 4px; transition: opacity 0.2s;}
.accordion-header:active { opacity: 0.6; }
.accordion-arrow { color: #C7C7CC; font-size: 20px; transition: transform 0.2s; margin-left: 5px;}
.accordion-item.expanded .accordion-arrow { transform: rotate(90deg); color: var(--neon-blue); }
.accordion-body { display: none; padding: 0 4px 14px 4px; border-top: none; cursor: default; }
.accordion-item.expanded .accordion-body { display: block; animation: fadeIn 0.3s ease; }
.sub-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed rgba(0,0,0,0.05); }
.sub-row:last-child { border-bottom: none; }

.glass-pill { padding: 5px 10px; border-radius: 10px; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; letter-spacing: -0.5px;}
.pill-draft { background: rgba(255, 159, 10, 0.15); color: var(--alert-orange); }
.pill-pending { background: rgba(10, 132, 255, 0.15); color: var(--neon-blue); }
.pill-confirmed { background: rgba(52, 199, 89, 0.15); color: var(--neon-green); }
.pill-neutral { background: rgba(0,0,0,0.05); color: var(--text-main); }

.modal-list-item { background: transparent; padding: 15px 4px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(0,0,0,0.06); cursor: pointer; transition: opacity 0.2s;}
.modal-list-item:active { opacity: 0.6; }
.modal-list-item:last-child { border-bottom: none; }

.segmented-control { display: flex; background: rgba(0,0,0,0.05); border-radius: 8px; padding: 4px; margin-bottom: 20px;}
.segment-btn { flex: 1; padding: 10px 0; text-align: center; color: #8e8e93; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 6px; transition: 0.2s; text-transform: uppercase;}
.segment-btn.active { background: #fff; color: #000; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; margin-bottom: 10px;}
.filter-pill { padding: 6px 12px; border-radius: 6px; background: rgba(0,0,0,0.05); color: #8e8e93; font-size: 12px; cursor: pointer; white-space: nowrap; }
.filter-pill.active { background: rgba(10, 132, 255, 0.1); color: var(--neon-blue); }

.compact-asset-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid rgba(0,0,0,0.05); color: #000;}
.compact-asset-item .ca-ticker { font-family: 'Courier New', Courier, monospace; font-weight: bold;}


/* ========================================= */
/* ИИ-ЧАТ (Архитектура 4.0 - Premium UI)     */
/* ========================================= */
.chat-layout {
    position: absolute !important; 
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    z-index: 50; 
    overflow: hidden !important; 
}

/* --- AMBIENT BACKGROUND --- */
.chat-ambient {
    position: absolute; 
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0; /* Строго ПОД сообщениями */
    overflow: hidden; 
    pointer-events: none; 
}

/* Шапка и Вкладки */
.chat-top-dock {
    flex-shrink: 0;
    padding: 15px 20px 10px 20px;
    background: rgba(229, 229, 234, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}
.chat-header-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn-danger {
    width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 69, 58, 0.1);
    color: var(--alert-red); border: none; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.2s; flex-shrink: 0;
}
.icon-btn-danger:active { transform: scale(0.9); }

/* Зона сообщений (ИСПРАВЛЕНО ПЕРЕКРЫТИЕ ТЕКСТА) */
.chat-scroll-area {
    flex: 1; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch;
    padding: 20px 20px 240px 20px; /* Увеличено со 180px до 240px, чтобы контент выезжал над доком */
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: none;
    z-index: 1; /* Поверх ambient-фона */
}
.chat-scroll-area::-webkit-scrollbar { display: none; }

/* --- iMESSAGE BOUNCE ANIMATION --- */
@keyframes bounceInUp {
    0% { opacity: 0; transform: translateY(20px) scale(0.95); }
    60% { opacity: 1; transform: translateY(-2px) scale(1.02); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.message {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 92%;
}
.message.animate-bounce {
    animation: bounceInUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: bottom left;
}

.message.user { align-self: flex-end; flex-direction: row-reverse; max-width: 85%; }
.message.user.animate-bounce { transform-origin: bottom right; }
.message.ai { align-self: flex-start; }

.msg-avatar {
    width: 32px; height: 32px; border-radius: 16px;
    background: var(--porcelain); display: flex; align-items: center;
    justify-content: center; color: var(--text-main); flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.03);
}

.msg-bubble {
    background: var(--porcelain); 
    padding: 16px 20px; 
    border-radius: 20px;
    color: var(--text-main); 
    font-size: 15px; 
    line-height: 1.55; 
    letter-spacing: -0.2px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03); 
    border: 1px solid rgba(0,0,0,0.02);
}
.message.user .msg-bubble { 
    background: var(--neon-blue); 
    color: #fff; 
    border-bottom-right-radius: 4px; 
}
.message.ai .msg-bubble { border-bottom-left-radius: 4px; }

.msg-author { font-size: 12px; color: var(--text-muted); font-weight: 700; margin-bottom: 6px; letter-spacing: 0; }
.message.user .msg-author { display: none; }

/* --- ТИПОГРАФИКА СООБЩЕНИЙ --- */
.msg-text ul, 
.msg-text ol {
    margin: 10px 0 10px 22px;
    padding: 0;
}
.msg-text li {
    margin-bottom: 6px;
    line-height: 1.5;
}
.msg-text ol {
    list-style-type: decimal;
}
.msg-text ul {
    list-style-type: disc;
}
.msg-text li:last-child {
    margin-bottom: 0;
}
.msg-text strong {
    font-weight: 800;
    color: inherit;
}

/* Интерактивные тикеры */
.copy-ticker {
    background: rgba(10, 132, 255, 0.1); color: var(--neon-blue);
    padding: 2px 6px; border-radius: 6px; font-family: 'Courier New', Courier, monospace;
    font-size: 13px; font-weight: 700; cursor: pointer; transition: 0.2s;
    display: inline-block; margin: 0 2px; white-space: nowrap;
}
.copy-ticker:active { transform: scale(0.95); }
.copy-ticker.copied { background: rgba(52, 199, 89, 0.15); color: var(--neon-green); }

/* ПАНЕЛЬ ВВОДА */
.chat-bottom-dock {
    position: absolute; 
    bottom: 0; left: 0; right: 0;
    padding: 0 20px calc(95px + env(safe-area-inset-bottom)) 20px;
    background: linear-gradient(180deg, rgba(229,229,234,0) 0%, rgba(229,229,234,0.9) 30%, rgba(229,229,234,1) 100%);
    pointer-events: none; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end; /* Жестко прижимаем элементы вниз */
    gap: 12px; /* Физический зазор между лимитами и полем ввода */
    z-index: 100;
    transition: padding 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.chat-layout.keyboard-active .chat-bottom-dock {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.chat-input-row {
    width: 100%;
    background: var(--porcelain);
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
    display: flex;
    align-items: flex-end;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.03);
    pointer-events: auto;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* --- NEON FOCUS GLOW --- */
.chat-layout.keyboard-active .chat-input-row {
    box-shadow: 0 0 15px rgba(10, 132, 255, 0.25);
    border-color: rgba(10, 132, 255, 0.4);
}

#chat-input {
    flex: 1; border: none; background: transparent; color: var(--text-main);
    font-size: 16px; resize: none; padding: 12px 0; height: 44px; outline: none; 
    line-height: 20px;
}
#chat-input::placeholder { color: var(--text-muted); }

/* iOS Style Dynamic Send Button */
.send-btn {
    width: 34px; height: 34px; border-radius: 17px; background: var(--text-muted); color: #fff; 
    border: none; display: flex; align-items: center; justify-content: center;
    cursor: default; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0; margin-left: 10px; margin-bottom: 5px; opacity: 0.5;
}
.send-btn.active {
    background: var(--neon-blue); opacity: 1; cursor: pointer;
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.3);
}
.send-btn.active:active { transform: scale(0.9); }
.send-btn.cooldown { background: rgba(0,0,0,0.1); color: var(--text-main); opacity: 1; cursor: not-allowed; box-shadow: none; }

/* Индикатор печати ИИ */
.typing-indicator { display: flex; gap: 4px; padding: 4px 2px; }
.typing-dot {
    width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ========================================= */
/* ПОРТФЕЛЬ 3.2.2: SYMMETRY & SMART POPOVERS */
/* ========================================= */
.portfolio-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    overflow: hidden;
}

.port-nav-header { padding: 15px 20px 0 20px; z-index: 10; display: flex; flex-direction: column; gap: 16px; flex-shrink: 0; }
.port-capsule-main { display: flex; background: rgba(0,0,0,0.05); border-radius: 30px; padding: 4px; align-items: center; }
.port-capsule-main .p-tab { flex: 1; padding: 10px 0; text-align: center; color: var(--text-muted); font-size: 14px; font-weight: 700; cursor: pointer; border-radius: 26px; transition: all 0.2s ease; }
.port-capsule-main .p-tab.active { background: var(--porcelain); color: var(--text-main); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }

.port-capsule-sub-row { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.port-capsule-sub { display: flex; gap: 8px; flex: 1; }
.p-sub-tab { flex: 1; text-align: center; padding: 8px 0; border-radius: 20px; background: rgba(0,0,0,0.05); color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.p-sub-tab.active { background: rgba(10, 132, 255, 0.1); color: var(--neon-blue); }

.p-filter-btn { width: 36px; height: 36px; border-radius: 18px; background: rgba(0,0,0,0.05); display: flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; transition: 0.2s; flex-shrink: 0; }
.p-filter-btn:active { transform: scale(0.9); }

/* Зона списков */
.port-lists-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* Увеличен отступ снизу под прибитый бар Сбера */
    padding: 5px 20px calc(90px + env(safe-area-inset-bottom)) 20px; 
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hidden { display: none !important; }
.q-section { display: flex; flex-direction: column; gap: 12px; }
.q-title { color: var(--alert-red); font-size: 14px; font-weight: 800; text-transform: uppercase; margin-left: 5px; }

.quarantine-glow {
    border: 1px solid rgba(255, 69, 58, 0.4) !important;
    box-shadow: 0 4px 15px rgba(255, 69, 58, 0.1) !important;
}

/* Сетка карточек (Строгая симметрия) */
.bento-grid-portfolio {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.port-bento-tile {
    background: var(--porcelain);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Прибивает элементы к краям, делая плитки симметричными */
    box-shadow: 0 6px 20px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.02);
    position: relative;
    height: 130px; /* Жесткая фиксация высоты */
}

.pbt-top { display: flex; justify-content: space-between; align-items: flex-start; }
.pbt-ticker { font-size: 15px; font-weight: 800; color: var(--text-main); font-family: 'Courier New', Courier, monospace; letter-spacing: -0.5px; }

.pbt-name {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 6px;
    /* Аппаратная обрезка длинного текста на 2 строки */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

.pbt-fin { display: flex; flex-direction: column; gap: 2px; }
.pbt-val { font-size: 16px; font-weight: 800; color: var(--text-main); }
.pbt-date { font-size: 11px; color: var(--neon-blue); font-weight: 700; }

/* Смарт-позиционирование Поповеров (Открытие ВНИЗ с учетом фильтров) */
.ai-risk-placeholder { font-size: 16px; cursor: pointer; user-select: none; transition: transform 0.2s; }
.badge-wrapper:active .ai-risk-placeholder { transform: scale(0.9); }

.badge-popover {
    position: absolute;
    width: 250px;
    z-index: 1000;
    top: calc(100% + 10px);
    bottom: auto;
    
    /* ПО УМОЛЧАНИЮ: Открываем вправо (для левой колонки) */
    left: -10px;
    transform: translateY(-10px) scale(0.95);
    transform-origin: top left;
}

.badge-popover.active { transform: translateY(0) scale(1); }

.badge-popover::after {
    content: ''; position: absolute;
    top: -7px; bottom: auto; left: 20px;
    border-width: 0 7px 7px 7px;
    border-style: solid;
    border-color: transparent transparent rgba(255, 255, 255, 0.85) transparent;
}

/* МОДИФИКАТОР (JS-Логика): Открываем влево (для правой колонки) */
.badge-popover.popover-left {
    right: -10px !important;
    left: auto !important;
    transform-origin: top right !important;
}

.badge-popover.popover-left::after {
    right: 20px !important;
    left: auto !important;
}

.ai-news-btn { width: 100%; margin-top: 10px; padding: 8px; border-radius: 8px; border: none; background: rgba(10, 132, 255, 0.1); color: var(--neon-blue); font-weight: 600; font-size: 12px; cursor: not-allowed; }

/* =========================================================
   МОДУЛЬ НОВОСТЕЙ 2.0 (СВЕТЛАЯ ТЕМА / GLASSMORPHISM)
   Адаптация под глобальный дизайн приложения
   ========================================================= */

#view-news {
    background: transparent !important; /* Пропускаем твои красивые фоновые градиенты */
    min-height: 100vh;
    width: 100%;
    color: #111; /* Темный текст по умолчанию */
}

.news-wrapper {
    padding: 0 15px; 
}

/* --- 1. ШАПКА И ПУЛЬС РЫНКА --- */
.port-nav-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 15px 0 10px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.market-mood-bar {
    display: flex;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    margin: 12px 0;
    background: rgba(0, 0, 0, 0.05);
}

.mood-segment { height: 100%; transition: width 0.5s ease; }
.mood-green { background: #34c759; } /* Мягкий iOS-зеленый */
.mood-red { background: #ff3b30; }   /* Мягкий iOS-красный */
.mood-gray { background: #d1d1d6; }

/* --- 2. ФИЛЬТРЫ И ТРЕНДЫ --- */
.news-segment-btn {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #8e8e93;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s ease;
}
.news-segment-btn.active {
    background: #ffffff;
    color: #000000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.hot-tickers-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    margin-bottom: 15px;
    scrollbar-width: none;
}
.hot-tickers-scroll::-webkit-scrollbar { display: none; }
.hot-capsule {
    padding: 5px 12px;
    background: #ffffff;
    border: 1px solid #e5e5ea;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #8e8e93;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.hot-capsule.active {
    background: rgba(255, 149, 0, 0.1);
    border-color: #ff9500;
    color: #d07500;
}

/* --- 3. ПЛАВАЮЩИЕ ДАТЫ --- */
.sticky-date {
    position: sticky;
    top: 105px; 
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 8px 0;
    font-size: 11px;
    color: #8e8e93;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 10;
    font-weight: 700;
    margin: 10px 0;
}

/* --- 4. КАРТОЧКА НОВОСТИ --- */
.news-feed-container { padding-bottom: 100px; }

.news-card {
    position: relative;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    margin-bottom: 15px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    transform: translateZ(0);
}

.news-edge {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: rgba(0, 0, 0, 0.05);
    z-index: 3;
}
.news-edge.positive { background: #34c759; }
.news-edge.negative { background: #ff3b30; }

/* --- 5. ВОДЯНЫЕ ЗНАКИ И СОДЕРЖИМОЕ --- */
.news-watermark {
    position: absolute;
    right: -10px;
    bottom: -10px;
    width: 100px;
    height: 100px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom right;
    
    /* УБИРАЕМ ОБЕСЦВЕЧИВАНИЕ, ПУСТЬ БУДУТ ЦВЕТНЫЕ */
    /* filter: grayscale(100%) contrast(1.5); */ 
    
    /* DARKEN оставляет темные участки картинки и убивает белые */
    mix-blend-mode: darken;
    
    /* ЖЕСТКО ВЫКРУЧИВАЕМ ПРОЗРАЧНОСТЬ ДО 35% */
    opacity: 0.6; 
    
    pointer-events: none;
    z-index: 1;
}



.news-content {
    padding: 14px 16px;
    position: relative;
    z-index: 2;
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #8e8e93;
    margin-bottom: 10px;
}
.news-source { font-weight: 700; text-transform: uppercase; color: #1c1c1e; }
.news-time { display: flex; align-items: center; gap: 6px; font-weight: 500; }

/* --- 6. МЕТКА NEW И ТИКЕРЫ --- */
.neon-dot {
    width: 6px;
    height: 6px;
    background: #007aff;
    border-radius: 50%;
    animation: pulse-dot-light 2s infinite;
}
@keyframes pulse-dot-light {
    0% { transform: scale(0.9); opacity: 1; box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4); }
    50% { transform: scale(1.1); opacity: 0.8; box-shadow: 0 0 0 4px rgba(0, 122, 255, 0); }
    100% { transform: scale(0.9); opacity: 1; box-shadow: 0 0 0 0 rgba(0, 122, 255, 0); }
}

.news-tickers { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.n-ticker {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: #f2f2f7;
    color: #8e8e93;
}
.n-ticker.in-portfolio { color: #007aff; background: rgba(0, 122, 255, 0.1); }
.n-ticker.in-candidates { color: #1c1c1e; background: #e5e5ea; }

/* --- 7. ЗАГОЛОВОК И АККОРДЕОН --- */
.news-title {
    font-size: 14px;
    color: #1c1c1e; /* Глубокий темный цвет для заголовка */
    line-height: 1.4;
    font-weight: 600;
}

.news-accordion {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}
.news-card.expanded .news-accordion {
    max-height: 300px;
    opacity: 1;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}
.news-summary {
    font-size: 13px;
    color: #3a3a3c;
    line-height: 1.5;
    margin-bottom: 12px;
}
.news-link {
    font-size: 12px;
    color: #007aff;
    text-decoration: none;
    font-weight: 600;
}

