html, body {
    margin:0; padding:0; width:100%; height:100%;
    font-family:'JetBrains Mono', monospace;
    background:#000; color:#fff;
    display:flex; flex-direction:column; align-items:center;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent; /* Убрать подсветку при тапе */
    touch-action: manipulation; /* Отключить двойной тап для зума */
  }
  
  /* Анимация загрузки */
  #loader {
    position:fixed; top:50%; left:50%;
    width:20px; height:20px;
    animation:blinkColors 2s infinite;
    transform:translate(-50%,-50%);
    will-change: background-color; /* Оптимизация для анимации */
  }
  @keyframes blinkColors { 
    0% { background:#1CAD66; }
    25% { background:#333; }
    50% { background:#E73049; }
    75% { background:#333; }
    100% { background:#1CAD66; }
  }
  
  /* Скрываем основной контент до загрузки */
  #mainContent { display:none; width:100%; flex:1 1 auto; flex-direction:column; align-items:center; padding-bottom: 150px; }
  
  /* Баланс и список */
  h1{ font-weight:400; font-size:1rem; margin-top:60px; margin-bottom:0.15em;}
  #totalBalance{ font-size:1rem; margin-bottom:1.6rem; text-align:center;}
  #accountsList{ width:90%; max-width:400px; flex:1 1 auto; overflow-y:auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .account{ display:flex; justify-content:space-between; padding:0.6em 0; }
  .account-name{ font-size:1.1rem; }
  .account-balance{ color:#ccc; text-align:right; }
  .account-details{ font-size:0.8rem; color:#666; margin-top:2px; }
  
  /* Блок долгов */
  #debtsSection { width:90%; max-width:400px; margin:1em 0 0 0; display:none; }
  #debtsSection h2 { font-weight:400; font-size:1rem; margin-bottom:1em; text-align:center; }
  .debt-item { display:flex; justify-content:space-between; padding:0.6em 0; border-bottom: none; }
  .debt-positive { color:#4CAF50; }
  .debt-negative { color:#f44336; }
  
  /* Кнопки */
  .buttons{ display:flex; flex-direction:column; gap:10px; position:fixed; bottom:20px; width:90%; max-width:400px; }
  .button-row{ display:flex; justify-content:space-around; gap:10px; }
  .btn{ background:#111; border:1px solid #333; padding:12px; border-radius:10px; cursor:pointer; flex:1; transition:0.2s; font-family:'JetBrains Mono', monospace; font-size:16px; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .btn:hover{ background:#222; }
  .income-btn{ color:#4CAF50; }
  .expense-btn{ color:#f44336; }
  .debt-btn{ color:#fff; }
  .transfer-btn{ color:#fff; }
  .stats-btn{ color:#fff; }
  
  /* Модалки */
  .modal {
    position:fixed; top:0; left:0; width:100%; height:100%;
    background:rgba(0,0,0,0.95); display:none; align-items:center; justify-content:center; z-index:1000;
  }
  .modal-content{
    background:#111; padding:1.5rem; border-radius:12px;
    width:90%; max-width:400px; max-height:90%; overflow-y:auto;
    display:flex; flex-direction:column; gap:10px;
  }
  
  /* Fullscreen modals */
  #historyModal .history-content,
  #statsModal .stats-content,
  #settingsModal .settings-content {
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding: 1.5rem;
    box-sizing: border-box;
    background: #111;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  
  #historyModal .history-content {
    background: #111;
    padding: 1.5rem;
    border-radius: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
  }
  
  #historyList {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    background: #000;
    -webkit-overflow-scrolling: touch; /* Плавный скролл на iOS */
    overscroll-behavior: contain; /* Предотвращает цепной скролл */
  }
  #historyModal .modal-content {
    width:100%; height:100%; border-radius:0; padding:1.5rem;
    box-sizing:border-box;
  }
  #statsModal .stats-content,
  #settingsModal .settings-content {
    width:100%; height:100%; border-radius:0; padding:1.5rem;
    box-sizing:border-box;
    }
  .stats-content .stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }
  .stats-content .stats-header h2 {
    margin: 0;
  }
  .stats-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;          /* adjust if your modal background is light */
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
  }
  .stats-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);  /* subtle hover */
  }
  input,select{ 
    padding:12px; 
    border-radius:6px; 
    border:1px solid #333; 
    background:#000; 
    color:#fff; 
    font-family:'JetBrains Mono', monospace; 
    font-size:16px; 
    height:44px;
    box-sizing:border-box;
    width:100%;
  }
  input[type="date"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }
  input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
  }
  .modal-content button{ 
    background:#333; 
    color:#fff; 
    border:none; 
    padding:12px; 
    border-radius:8px; 
    cursor:pointer; 
    font-family:'JetBrains Mono', monospace;
    font-size:16px; 
    height:44px;
    width:100%;
  }
  .modal-content button:hover{ background:#555;}
  #historyList{ font-size:0.85rem; flex:1; overflow-y:auto;}
  
  .history-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    width: 100%;
    border-bottom: 1px solid #222;
  }
  
  .history-text {
    flex: 1;
    min-width: 0;
    padding-right: 10px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-wrap: break-word;
    line-height: 1.5;
  }
  
  .history-arrow { margin:0 5px; }
  
  .history-details {
    font-size: 0.75rem;
    color: #666;
    margin-top: 4px;
  }
  
  .delete-btn {
    color: #f55 !important;
    cursor: pointer;
    border: none !important;
    background: none !important;
    font-size: 24px !important;
    font-family: 'JetBrains Mono', monospace;
    width: 36px !important;
    height: 36px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    flex-shrink: 0;
    padding: 0 !important;
    margin: 0;
    -webkit-text-size-adjust: 100%;
    -webkit-user-select: none;
    user-select: none;
  }
  
  .delete-btn:hover { 
    background: rgba(255, 85, 85, 0.1) !important; 
  }
  
  .auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .auth-buttons {
    display: flex;
    gap: 10px;
  }
  
  .auth-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid #333;
    background: #000;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-family:'JetBrains Mono', monospace;
  }
  
  .auth-btn:hover {
    background: #222;
  }
  
  .history-top-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 10px;
    z-index: 100;
    transition: 0.2s;
    font-family:'JetBrains Mono', monospace;
  }
  
  .history-top-btn:hover {
    background: #222;
  }
  
  .settings-top-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 10px;
    z-index: 100;
    transition: 0.2s;
    font-family:'JetBrains Mono', monospace;
  }
  
  .settings-top-btn:hover {
    background: #222;
  }
  
  .stats-top-btn {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #111;
    border: 1px solid #333;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 10px;
    z-index: 100;
    transition: 0.2s;
    font-family:'JetBrains Mono', monospace;
  }
  
  .stats-top-btn:hover {
    background: #222;
  }
  
  .logout-top-btn {
    background: #111;
    border: 1px solid #333;
    color: #f55;
    cursor: pointer;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 10px;
    transition: 0.2s;
    font-family:'JetBrains Mono', monospace;
    margin-right: 10px;
  }
  
  .logout-top-btn:hover {
    background: #222;
  }
  
  /* Настройки */
  .settings-content {
    background:#111;
    padding:1.5rem;
    border-radius:0;
    width:100%;
    height:100%;
    overflow-y:auto;
    display:flex;
    flex-direction:column;
    gap:15px;
    box-sizing:border-box;
  }
  
  .user-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-direction: row;
  }
  
  .user-display span {
    order: 1;
    flex: 1;
  }
  
  .user-display .logout-top-btn {
    order: 2;
    flex-shrink: 0;
  }
  
  .tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
  }
  
  .tab {
    flex: 1;
    padding: 10px;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
    font-size: 12px;
    font-family:'JetBrains Mono', monospace;
    min-width: 80px;
  }
  
  .tab.active {
    background: #333;
  }
  
  .settings-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    background: #000;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  .settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #333;
    min-width: 0;
  }
  
  .settings-item:last-child {
    border-bottom: none;
  }
  
  .add-btn-small {
    padding: 12px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family:'JetBrains Mono', monospace;
    margin-bottom: 16px;
  }
  
  .add-btn-small:hover {
    background: #555;
  }
  
  .settings-item > span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
  }
  
  .close-btn {
    padding: 12px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family:'JetBrains Mono', monospace;
    font-size: 16px;
  }
  
  .close-btn:hover {
    background: #555;
  }
  
  .color-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
  }
  
  .eye-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ccc;
    transition: color 0.2s;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    flex-shrink: 0;
  }
  
  .eye-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  
  .eye-icon:hover {
    color: #fff;
  }
  
  .eye-icon.hidden {
    opacity: 0.5;
  }
  
  .eye-icon.hidden::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1.5px;
    background: currentColor;
    transform: translateY(-50%) rotate(45deg);
    transform-origin: center;
    pointer-events: none;
  }
  
  .input-row {
    display: flex;
    gap: 10px;
    align-items: center;
  }
  
  .full-width-input {
    width: 100%;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #000;
    color: #fff;
    font-family:'JetBrains Mono', monospace;
    font-size: 16px;
    height: 44px;
    box-sizing: border-box;
  }
  
  .color-input {
    width: 80px;
    text-align: center;
    flex-shrink: 0;
  }
  
  .currency-input {
    width: 100px;
    text-align: center;
    flex-shrink: 0;
  }
  
  /* Статистика */
  .stats-content {
    background:#111;
    padding:1.5rem;
    border-radius:0;
    width:100%;
    height:100%;
    overflow-y:auto;
    display:flex;
    flex-direction:column;
    gap:15px;
    box-sizing:border-box;
  }
  
  .stats-section {
    margin-bottom: 20px;
  }
  
  .stats-section h3 {
    font-weight: 400;
    font-size: 1rem;
    margin-bottom: 10px;
    color: #ccc;
  }
  
  .stats-section > div:last-child {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .stats-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #222;
  }
  
  .stats-positive {
    color: #4CAF50;
  }
  
  .stats-negative {
    color: #f44336;
  }
  
  .stats-comparison {
    font-size: 0.8rem;
    color: #666;
  }
  
  .stats-category {
    padding: 0.6em 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .stats-second-row {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    min-width: 0;
  }
  
  .stats-bar {
    flex: 1;
    min-width: 0;
    height: 8px;
    background: #333;
    border-radius: 4px;
  }
  
  .stats-income-bar-fill {
    height: 100%;
    background: #4CAF50;
    border-radius: 4px;
  }
  
  .stats-expense-bar-fill {
    height: 100%;
    background: #E73049;
    border-radius: 4px;
  }
  
  .stats-numbers {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }
  
  .stats-amount {
    color: #fff;
    font-size: 0.9rem;
  }
  
  .stats-percentage {
    color: #666;
    font-size: 0.9rem;
  }
  
  /* Адаптивность для мобильных */
  @media (max-width: 480px) {
    .stats-second-row {
      gap: 10px;
    }
    
    .stats-bar {
      min-width: 100px;
    }
    
    .stats-numbers {
      font-size: 0.8rem;
    }
  }
  
  .period-btn {
    flex: 1;
    padding: 8px;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family:'JetBrains Mono', monospace;
  }
  
  .period-btn.active {
    background: #333;
  }
  
  .period-picker {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
  }
  
  .period-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
  }
  
  .year-select,
  .month-select,
  .quarter-select {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #000;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    flex: 1;
    min-width: 120px;
  }
  
  .period-picker-row {
    display: flex;
    gap: 10px;
    width: 100%;
  }
  
  /* Валютные курсы */
  .exchange-rate {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
  }
  
  /* Адаптивные улучшения */
  @media (max-width: 380px) {
    .tabs {
      gap: 3px;
    }
    
    .tab {
      font-size: 10px;
      padding: 8px 5px;
      min-width: 70px;
    }
    
    .button-row {
      gap: 5px;
    }
    
    .btn {
      padding: 10px;
      font-size: 14px;
    }
  }
  
  /* Анимации */
  .fade-in {
    animation: fadeIn 0.3s ease-in;
    will-change: opacity, transform; /* Оптимизация для анимации */
  }
  
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  /* Custom dialogs */
  .custom-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
  }
  
  .custom-dialog-content {
    background: #111;
    padding: 1.5rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .custom-dialog-title {
    font-size: 1.2rem;
    font-weight: 400;
    margin-bottom: 8px;
  }
  
  .custom-dialog-message {
    color: #ccc;
    line-height: 1.5;
  }
  
  .custom-dialog-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px;
  }
  
  .custom-dialog-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid #333;
    background: #222;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    transition: 0.2s;
  }
  
  .custom-dialog-btn:hover {
    background: #333;
  }
  
  .custom-dialog-btn.primary {
    background: #333;
  }
  
  .custom-dialog-btn.primary:hover {
    background: #444;
  }
  
  .custom-dialog-btn.danger {
    background: #4d1a1a;
    border-color: #f55;
    color: #f55;
  }
  
  .custom-dialog-btn.danger:hover {
    background: #5d2a2a;
  }
  
  /* Loading animation */
  .loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #333;
    border-top-color: #1CAD66;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
    will-change: transform; /* Оптимизация для анимации */
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  .history-loading {
    text-align: center;
    padding: 20px;
    color: #666;
  }