/* === ПЕРЕМЕННЫЕ === */
:root {
    color-scheme: dark;
    --bg-color: #000000;
    --card-bg: #1C1C1E;
    --input-bg: #2C2C2E;
    --primary: #3A7D73;
    --primary-hover: #2F665E;
    --success: #32D74B;
    --danger: #FF453A;
    --warning: #FFD60A;
    --text-main: #FFFFFF;
    --text-secondary: #8E8E93;
    --border: rgba(255, 255, 255, 0.15);
    --radius-card: 20px;
    --radius-input: 14px;
    --radius-btn: 14px;
    /* Базовый отступ сверху (для браузера) */
    --body-padding-top: 20px;
}

/* --- LIGHT THEME --- */
[data-theme="light"] {
    color-scheme: light;
    --bg-color: #F2F2F7;
    --card-bg: #FFFFFF;
    --input-bg: #E5E5EA;
    --text-main: #000000;
    --text-secondary: #8E8E93;
    --border: rgba(60, 60, 67, 0.12);
    --primary: #2D6A60;
}

/* === БАЗА === */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
    height: 100%;
    background-color: var(--bg-color);
}

/* Если мы в Telegram (класс добавит JS) */
body.telegram-view {
    --body-padding-top: 40px;
}
body.telegram-view[data-platform="ios"] {
    --body-padding-top: 40px; /* Доп отступ для iOS */
}

body {
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    margin: 0;

    /* ОТСТУПЫ */
    padding-top: var(--body-padding-top);
    padding-left: 20px;
    padding-right: 20px;
    /* Отступ снизу под меню + безопасная зона */
    padding-bottom: calc(100px + env(safe-area-inset-bottom));

    /* ВАЖНО: display: block для нормального скролла */
    display: block;
}

a { text-decoration: none; color: inherit; }
h1, h2, h3 { margin: 0 0 15px 0; font-weight: 700; }
.container { max-width: 600px; margin: 0 auto; }

/* === КОМПОНЕНТЫ === */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-card);
    padding: 20px;
    margin-bottom: 16px;
}

/* Списки */
.list-item, .tx-item, .menu-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    width: 100%;
}
.list-item:last-child, .tx-item:last-child, .menu-btn:last-child {
    border-bottom: none;
}

.list-left {
    display: flex; align-items: center; gap: 15px; flex-grow: 1; overflow: hidden;
}
.list-right {
    display: flex; align-items: center; gap: 15px; text-align: right; flex-shrink: 0;
}

/* Иконки */
.icon-box {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.icon-box.income { background: rgba(76, 217, 100, 0.15); color: var(--success); }
.icon-box.expense { background: rgba(255, 255, 255, 0.05); color: var(--text-main); }

.amount { font-weight: 600; font-size: 16px; white-space: nowrap; }
.amount.income { color: var(--success); }
.amount.expense { color: var(--text-main); }

/* Кнопки и Формы */
.btn {
    background: var(--primary); color: #fff; border: none;
    padding: 16px; border-radius: 14px; font-weight: 600;
    width: 100%; display: flex; justify-content: center; align-items: center; gap: 8px;
}
.form-control {
    background-color: var(--input-bg) !important;
    border: 1px solid transparent;
    color: var(--text-main) !important;
    padding: 16px;
    border-radius: var(--radius-input);
    width: 100%;
    margin-bottom: 20px;
    font-size: 17px;
    appearance: none;
}
select.form-control {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Утилиты */
.text-secondary { color: var(--text-secondary); }
.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-xl { font-size: 24px; font-weight: 700; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-10 { gap: 10px; }
.mb-20 { margin-bottom: 20px; }

/* === ШТОРКА (MODAL SHEET) === */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 1000;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
    position: fixed;
    bottom: 0; /* Всегда прижат к низу */
    left: 0; width: 100%;
    background: var(--card-bg);
    border-radius: 24px 24px 0 0;
    padding: 25px 20px 40px 20px;
    z-index: 1001;

    /* Скрываем сдвигом вниз на 100% */
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bottom-sheet.open {
    /* Показываем, убирая сдвиг */
    transform: translateY(0);
}

.sheet-handle {
    width: 40px; height: 5px; background: #3A3A3C;
    margin: 0 auto 20px auto; border-radius: 10px;
}

/* === НИЖНЕЕ МЕНЮ === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--border);
    display: flex; justify-content: space-around;
    padding-top: 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 1000;
}
.nav-item {
    color: var(--text-secondary);
    font-size: 10px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: none; border: none; cursor: pointer; flex: 1;
}
.nav-item i { font-size: 24px; }
.nav-item.active { color: var(--primary); }

/* === FAB (+) === */
.fab {
    position: fixed;
    bottom: calc(95px + env(safe-area-inset-bottom));
    right: 20px;
    background: var(--primary); color: white;
    width: 56px; height: 56px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    box-shadow: 0 8px 20px rgba(58, 125, 115, 0.4);
    z-index: 990; border: none;
}

/* Чекбокс в форме */
input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    vertical-align: middle;
    margin-right: 10px;
}
/* Чтобы лейбл стоял рядом */
label[for*="is_main"] {
    display: inline-block;
    vertical-align: middle;
    margin-bottom: 0;
}

/* === PRO LOCK STYLES === */
.pro-lock-container {
    position: relative;
    overflow: hidden;
}

.pro-blur {
    filter: blur(5px);
    opacity: 0.6;
    pointer-events: none; /* Чтобы нельзя было кликнуть */
    user-select: none;
}

.pro-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background: rgba(0,0,0,0.2); /* Легкое затемнение */
}

.lock-badge {
    background: rgba(28, 28, 30, 0.9);
    border: 1px solid var(--warning);
    color: var(--warning);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}