/* Стили по образцу asserts/Трекер расходов — Mini App.html */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --primary: #5b47e0;
  --primary-container: #6552e9;
  --on-primary-container: #f3f59a;
  --secondary-container: #f3f59a;
  --on-secondary-container: #2d2487;
  --tertiary: #007a5e;
  --tertiary-container: #c4f2de;
  --on-tertiary-container: #00382a;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --background: #f8f6ff;
  --on-surface: #1b1830;
  --on-surface-variant: #4a4566;
  --outline: #78729a;
  --outline-variant: #cbc5e3;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f2efff;
  --surface-container: #ece8fd;
  --surface-container-high: #e6e1fa;
  --primary-fixed: #e4dfff;
  --on-primary-fixed-variant: #3f2cc0;
  --brand-mint: #a8ebcf;
  --shape-small: 8px;
  --shape-medium: 12px;
  --shape-large: 20px;
  --shape-extra-large: 32px;
  --font: Onest, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--background); color: var(--on-surface); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--primary); }
input, select, textarea { font-family: inherit; font-size: 16px; color: var(--on-surface); }

#app { max-width: 560px; margin: 0 auto; padding-bottom: 96px; transition: opacity 0.15s; }
#app.busy { opacity: 0.5; pointer-events: none; transition-delay: 0.15s; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; gap: 8px; }
.top h1 { margin: 0; font-size: 28px; line-height: 36px; font-weight: 700; letter-spacing: -0.25px; }
.chip-budget { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 16px; border: 0; border-radius: 9999px; background: var(--secondary-container); color: var(--on-secondary-container); font-size: 14px; line-height: 20px; font-weight: 600; }

.month { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.month span { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: 0.15px; }
.icon-btn { width: 48px; height: 48px; border: 0; background: transparent; color: var(--primary); display: flex; align-items: center; justify-content: center; border-radius: 9999px; }
.icon-btn:disabled { opacity: 0.38; }

.hero { margin: 4px 16px 0; padding: 20px 24px; border-radius: var(--shape-extra-large); background: var(--primary-container); color: var(--on-primary-container); display: flex; flex-direction: column; gap: 12px; }
.hero .label { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; }
.hero .total { font-size: 40px; line-height: 48px; font-weight: 700; letter-spacing: -1px; }
.hero .total small { font-size: 24px; letter-spacing: 0; }
.hero .total-usd { font-size: 16px; line-height: 24px; font-weight: 500; opacity: 0.85; }
.hero .bar { display: flex; height: 12px; border-radius: 9999px; overflow: hidden; gap: 3px; background: rgba(255,255,255,0.15); }
.hero .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; line-height: 16px; letter-spacing: 0.4px; }
.hero .legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 9999px; display: inline-block; }
.hero .note { font-size: 12px; line-height: 16px; opacity: 0.9; }

.filters { display: flex; gap: 8px; padding: 12px 16px 4px; overflow-x: auto; }
.filter { height: 32px; padding: 0 16px; border: 1px solid var(--outline); border-radius: var(--shape-small); background: transparent; color: var(--on-surface-variant); font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; }
.filter[aria-pressed="true"] { display: flex; align-items: center; gap: 6px; padding: 0 12px 0 8px; border: 0; border-radius: 9999px; background: var(--secondary-container); color: var(--on-secondary-container); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
/* Шапка дня — липкая тональная плашка; фон непрозрачный, иначе строки просвечивают при прокрутке.
   z-index ниже .nav (5) и шторок (10); у соседних шапок одинаковый, поэтому следующий день перекрывает предыдущий. */
.day { position: sticky; top: 0; z-index: 1; margin-top: 8px; padding: 6px 16px; min-height: 32px; background: var(--surface-container); font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; color: var(--primary); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.day > :first-child { flex: none; white-space: nowrap; }
/* Итог дня — подпись, а не число: мельче и тише сумм покупок. Переносится только между валютами. */
.day-total { min-width: 0; text-align: right; font-size: 12px; line-height: 16px; letter-spacing: 0.4px; color: var(--on-surface-variant); }
.day-total > span { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 16px; padding: 8px 16px; min-height: 56px; width: 100%; border: 0; background: transparent; text-align: left; color: var(--on-surface); }
.row:active { background: var(--surface-container-low); }
.mark { width: 44px; height: 44px; flex: none; border-radius: 9999px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 500; }
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .title { font-size: 16px; line-height: 24px; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 14px; line-height: 20px; letter-spacing: 0.25px; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amount { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: 0.15px; white-space: nowrap; }
.empty { padding: 48px 24px; text-align: center; color: var(--on-surface-variant); font-size: 14px; line-height: 20px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; height: 80px; background: var(--surface-container); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: transparent; color: var(--on-surface-variant); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.5px; }
.nav .pill { width: 64px; height: 32px; border-radius: 9999px; display: flex; align-items: center; justify-content: center; }
.nav button[aria-current="page"] { color: var(--on-surface); }
.nav button[aria-current="page"] .pill { background: var(--secondary-container); color: var(--on-secondary-container); }

.section { margin: 16px 16px 0; }
.section h2 { margin: 0 0 8px; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: 0.15px; }
.section .hint, .sheet .hint { margin: 0 0 8px; font-size: 14px; line-height: 20px; color: var(--on-surface-variant); }
.card { background: var(--surface-container-lowest); border-radius: var(--shape-large); padding: 4px 0; }
.card .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 56px; }
.card .item + .item { border-top: 1px solid var(--surface-container); }
.card .item .grow { flex: 1; min-width: 0; }
.card .item .sub { font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 9999px; font-size: 12px; line-height: 16px; font-weight: 500; background: var(--surface-container-high); color: var(--on-surface-variant); white-space: nowrap; }
.badge.ok { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.badge.bad { background: var(--error-container); color: var(--error); }
.badge.main { background: var(--secondary-container); color: var(--on-secondary-container); }

.btn { height: 40px; padding: 0 20px; border: 0; border-radius: 9999px; background: var(--primary); color: #fff; font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: 0.1px; }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.text { background: transparent; color: var(--primary); padding: 0 12px; }
.btn.danger { background: var(--error-container); color: var(--error); }
.btn:disabled { opacity: 0.38; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.small-btn { height: 32px; padding: 0 12px; border: 1px solid var(--outline-variant); border-radius: var(--shape-small); background: transparent; color: var(--on-surface-variant); font-size: 13px; font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--on-surface-variant); letter-spacing: 0.4px; }
.field input, .field select, .field textarea { height: 48px; padding: 0 14px; border: 1px solid var(--outline); border-radius: var(--shape-small); background: var(--surface-container-lowest); width: 100%; }
.field textarea { height: 72px; padding: 12px 14px; resize: none; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; }
.inline > .fit { flex: none; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.32); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; background: var(--surface-container-low); border-radius: 28px 28px 0 0; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet .grip { width: 32px; height: 4px; border-radius: 9999px; background: var(--outline); margin: 8px auto 16px; opacity: 0.4; }
.sheet h3 { margin: 0 0 16px; font-size: 22px; line-height: 28px; font-weight: 600; }
.items { margin: 0 0 12px; padding: 0; list-style: none; font-size: 14px; line-height: 20px; color: var(--on-surface-variant); }
.items li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }

.bars { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.bars .bar-row { display: flex; flex-direction: column; gap: 4px; }
.bars .bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; line-height: 20px; }
.bars .bar-head b { font-weight: 600; white-space: nowrap; }
.bars .track { height: 10px; border-radius: 9999px; background: var(--surface-container); overflow: hidden; }
.bars .fill { height: 100%; border-radius: 9999px; background: var(--primary); }
.columns { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: 16px 16px 4px; }
.columns .col { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.columns-axis { display: flex; justify-content: space-between; padding: 0 16px 12px; font-size: 11px; color: var(--on-surface-variant); }
.segmented { display: flex; margin: 12px 16px 0; border: 1px solid var(--outline); border-radius: 9999px; overflow: hidden; }
.segmented button { flex: 1; height: 40px; border: 0; background: transparent; color: var(--on-surface); font-size: 14px; font-weight: 500; }
.segmented button + button { border-left: 1px solid var(--outline); }
.segmented button[aria-pressed="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }

.toast { position: fixed; left: 16px; right: 16px; bottom: 96px; margin: 0 auto; max-width: 528px; padding: 14px 16px; border-radius: var(--shape-small); background: #302c48; color: #f3f0ff; font-size: 14px; line-height: 20px; z-index: 20; }
.loading { padding: 48px; text-align: center; color: var(--on-surface-variant); }
.muted { color: var(--on-surface-variant); }
.mono { font-variant-numeric: tabular-nums; }
.inline input { height: 48px; padding: 0 14px; border: 1px solid var(--outline); border-radius: var(--shape-small); background: var(--surface-container-lowest); min-width: 0; }
.inline input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.inline input::placeholder { text-transform: none; }
.inline .btn { height: 48px; }
.card .item .grow { overflow-wrap: break-word; }
.card .item.stacked { flex-direction: column; align-items: stretch; gap: 8px; }
.card .item .row-head { display: flex; align-items: center; gap: 12px; }
.card .item .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-small { width: 40px; height: 40px; flex: none; display: flex; align-items: center; justify-content: center; border: 1px solid var(--outline-variant); border-radius: 9999px; background: transparent; color: var(--on-surface-variant); }
.icon-small svg { width: 20px; height: 20px; }
.icon-small:active { background: var(--surface-container); }

/* Стрелка выпадающего списка с тем же отступом от края, что и текст. */
.field select { appearance: none; -webkit-appearance: none; padding-right: 44px; background-repeat: no-repeat; background-position: right 14px center; background-size: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A4566' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.date-input { position: relative; height: 48px; display: flex; align-items: center; padding: 0 44px 0 14px; border: 1px solid var(--outline); border-radius: var(--shape-small); background-color: var(--surface-container-lowest);
  background-repeat: no-repeat; background-position: right 14px center; background-size: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A4566' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E"); }
.date-input:focus-within { outline: 2px solid var(--primary); border-color: transparent; }
.date-input .date-label { font-size: 16px; }
.field .date-input input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.hero .hero-wordmark { display: block; height: 30px; width: auto; margin-bottom: 4px; }
