/* Rashody — чёрная тема, белый текст */
:root {
    --bg: #000000;
    --card: #121212;
    --card-2: #1a1a1a;
    --border: #242424;
    --text: #ffffff;
    --muted: #9a9a9e;
    --accent: #0a84ff;
    --green: #34c759;
    --red: #ff453a;
    --yellow: #ffd60a;
    --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    height: 100%;
}

#app { min-height: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.value { font-size: 22px; font-weight: 700; }
.value.expense { color: var(--red); }
.value.income { color: var(--green); }
.big-emoji { font-size: 44px; margin-bottom: 12px; }

/* --- Экраны --- */
.screen { padding: 24px; }
.center-screen {
    min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.spinner {
    width: 36px; height: 36px; margin-bottom: 14px;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Шапка --- */
#topbar {
    position: sticky; top: 0; z-index: 20;
    padding: 16px 16px 10px;
    background: rgba(0,0,0,0.9); backdrop-filter: blur(12px);
}
#topbar h1 { font-size: 24px; font-weight: 800; }
#topbar-sub { font-size: 13px; margin-top: 2px; }

#content { padding: 8px 16px 140px; }

/* --- Карточки --- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0; }
.card-row .value { white-space: nowrap; }
.two-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.two-cards .card { margin-bottom: 0; }
.mini-card { display: flex; flex-direction: column; gap: 6px; }
.mini-card.wide { margin-bottom: 12px; }
.day-total-row { padding: 12px 4px; }

.section-title { font-size: 15px; font-weight: 700; margin: 18px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Прогресс бюджета --- */
.progress-wrap {
    height: 10px; background: var(--card-2);
    border-radius: 6px; overflow: hidden; margin: 12px 0;
}
.progress-bar {
    height: 100%; width: 0%;
    background: var(--accent); border-radius: 6px;
    transition: width 0.4s ease, background 0.4s ease;
}
.progress-bar.warn { background: var(--yellow); }
.progress-bar.over { background: var(--red); }

/* --- Списки --- */
.list { display: flex; flex-direction: column; gap: 8px; }
.entry {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 14px;
    cursor: pointer;
}
.entry:active { background: var(--card-2); }
.entry-ico {
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: 12px; background: var(--card-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.entry-ico img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; }
.entry-body { flex: 1; min-width: 0; }
.entry-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.entry-amount { font-size: 15px; font-weight: 700; white-space: nowrap; flex-shrink: 0; text-align: right; }
.entry-amount.income { color: var(--green); }
.entry-amount.expense { color: var(--text); }
/* Подпись «≈ сумма в основной валюте» под записью в другой валюте */
.entry-amount .conv { display: block; font-size: 11px; font-weight: 400; color: var(--muted, #8e8e93); margin-top: 2px; }

/* --- Категории в статистике --- */
/* .bar-row используется вместе с .entry: переопределяем flex в блок,
   иначе заголовок и полоса прогресса встают в один ряд и верстка едет. */
.bar-row { display: block; padding: 10px 14px; }
.bar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.bar-top span:last-child { color: var(--muted); white-space: nowrap; }
.bar-track { height: 8px; background: var(--card-2); border-radius: 4px; overflow: hidden; }

/* --- Сегментированный переключатель --- */
.segmented {
    display: flex; background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; padding: 3px; margin-bottom: 12px;
}
.seg-btn {
    flex: 1; padding: 8px 4px; border: none; border-radius: 9px;
    background: transparent; color: var(--muted);
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-btn.active { background: var(--card-2); color: var(--text); }

/* --- Навигация по периодам --- */
.period-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 0 4px; }
.period-nav span { font-size: 16px; font-weight: 700; }
.nav-btn {
    width: 40px; height: 34px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--card); color: var(--text); font-size: 20px; cursor: pointer;
}
.stats-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stats-cards .card { margin-bottom: 0; }

/* --- Кнопки и поля --- */
.btn {
    border: 1px solid var(--border); background: var(--card-2); color: var(--text);
    border-radius: 12px; padding: 10px 16px; font-size: 15px; font-weight: 600;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { opacity: 0.7; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: none; color: var(--muted); font-size: 18px; padding: 6px 10px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: 0.5; }

.input {
    width: 100%; background: var(--card-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 14px; font-size: 16px; outline: none;
    color-scheme: dark;
}
.input:focus { border-color: var(--accent); }
.input.big { font-size: 26px; font-weight: 700; padding: 14px; }
.input.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
select.input { appearance: none; }
.row { display: flex; gap: 8px; align-items: center; }
.row .input { flex: 1; }
label.muted { display: block; margin: 14px 0 6px; }

/* --- FAB и нижняя навигация --- */
#fab {
    position: fixed; right: 20px; bottom: 92px; z-index: 30;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--accent); color: #fff; border: none;
    font-size: 30px; font-weight: 500; cursor: pointer;
    box-shadow: 0 6px 24px rgba(10,132,255,0.45);
}
#tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; background: rgba(10,10,10,0.92);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(14px);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab {
    flex: 1; border: none; background: transparent; color: var(--muted);
    font-size: 11px; padding: 10px 4px 8px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab .tab-ico { font-size: 20px; }
.tab.active { color: var(--text); }

/* --- Модалка --- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
    width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
    background: #0d0d0d; border: 1px solid var(--border);
    border-radius: 22px 22px 0 0; padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
    animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0.5; } to { transform: translateY(0); opacity: 1; } }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-header h3 { font-size: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    border: 1px solid var(--border); background: var(--card-2); color: var(--text);
    border-radius: 20px; padding: 8px 12px; font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); }

.photo-btn { cursor: pointer; }
.photo-preview {
    margin-top: 10px; width: 100%; max-height: 220px; object-fit: cover;
    border-radius: 12px; border: 1px solid var(--border);
}
.wide-btn { width: 100%; margin-top: 20px; padding: 14px; font-size: 17px; }

/* --- Тост --- */
.toast {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: 100px; z-index: 60;
    background: var(--card-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 18px; font-size: 14px; max-width: 86vw;
    animation: slideUp 0.2s ease;
}

.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s ease; }

#screen-error p#error-text { white-space: pre-line; line-height: 1.5; max-width: 82vw; }
