/* ============================================================
   Копилка — дизайн-система
   Токены → базовые стили → компоненты → экраны
   ============================================================ */

:root {
  /* spacing (сетка 4/8) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* радиусы */
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px; --r-pill: 999px;

  /* типографика */
  --f-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-display: 30px; --t-title: 21px; --t-head: 17px; --t-body: 15px;
  --t-label: 13px; --t-cap: 11px;

  /* motion */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: .22s;

  --tab-h: 62px;
}

/* ---------- темы ---------- */
html[data-theme="light"] {
  --bg: #F4F5F8;
  --bg-deep: #E9EBF0;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EEF0F4;
  --text: #111420;
  --text-2: #666E7E;
  --text-3: #98A0AE;
  --border: #E4E7ED;
  --border-strong: #D3D8E1;
  --primary: #3B5BFF;
  --primary-2: #6E7BFF;
  --primary-soft: #EBEEFF;
  --on-primary: #FFFFFF;
  --success: #0E9F62;
  --success-soft: #E4F6ED;
  --danger: #E0403A;
  --danger-soft: #FDECEB;
  --warning: #D98200;
  --warning-soft: #FDF3E2;
  --shadow-1: 0 1px 2px rgba(17, 20, 32, .05);
  --shadow-2: 0 8px 24px -12px rgba(17, 20, 32, .18);
  --shadow-3: 0 18px 40px -16px rgba(17, 20, 32, .28);
  --scrim: rgba(17, 20, 32, .38);
  --hero-1: #2E48E8; --hero-2: #6C7BFF;
}

html[data-theme="dark"] {
  --bg: #0C0E14;
  --bg-deep: #06070B;
  --surface: #15181F;
  --surface-2: #1B1F27;
  --surface-3: #232833;
  --text: #F1F3F8;
  --text-2: #99A1B0;
  --text-3: #6E7686;
  --border: #272C36;
  --border-strong: #353B47;
  --primary: #6C86FF;
  --primary-2: #93A4FF;
  --primary-soft: #1D2440;
  --on-primary: #0A0C12;
  --success: #35C98A;
  --success-soft: #12281F;
  --danger: #FF7A72;
  --danger-soft: #2C1716;
  --warning: #F2B44C;
  --warning-soft: #2A2114;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 10px 26px -14px rgba(0, 0, 0, .7);
  --shadow-3: 0 20px 44px -18px rgba(0, 0, 0, .8);
  --scrim: rgba(0, 0, 0, .58);
  --hero-1: #2A3EC8; --hero-2: #5566E0;
}

/* ---------- базовое ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--f-sans);
  background: var(--bg-deep);
  color: var(--text);
  font-size: var(--t-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg.ic { display: block; flex: none; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---------- каркас ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 0 60px -20px rgba(0, 0, 0, .25);
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4) var(--s2);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}
.topbar__titles { flex: 1; min-width: 0; }
.topbar__sub { font-size: var(--t-label); color: var(--text-2); }
.topbar__title { font-size: var(--t-title); font-weight: 700; letter-spacing: -.02em; }
.topbar__actions { display: flex; gap: var(--s1); }

.screen {
  flex: 1;
  padding: var(--s2) var(--s4) calc(var(--tab-h) + var(--s10) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s4);
}

/* ---------- кнопки ---------- */
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn--accent { background: var(--primary-soft); color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5);
  border-radius: var(--r-md);
  font-weight: 600; font-size: var(--t-body);
  background: var(--surface-3); color: var(--text);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-2); }
.btn--ghost { background: transparent; color: var(--primary); }
.btn--soft { background: var(--primary-soft); color: var(--primary); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 var(--s4); font-size: var(--t-label); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--primary); font-weight: 600; font-size: var(--t-label);
  padding: var(--s2) var(--s1);
}

/* ---------- карточки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--shadow-1);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s3);
}
.card__title { font-size: var(--t-head); font-weight: 650; letter-spacing: -.01em; }
.card__hint { font-size: var(--t-label); color: var(--text-2); }
.section-title {
  font-size: var(--t-label); font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3);
  margin: 0 var(--s1) calc(-1 * var(--s1));
}

/* ---------- герой (баланс) ---------- */
.hero {
  border-radius: var(--r-xl);
  padding: var(--s5);
  color: #fff;
  background: linear-gradient(150deg, var(--hero-1) 0%, var(--hero-2) 100%);
  box-shadow: var(--shadow-3);
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -50px; top: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; position: relative; z-index: 1; }
.hero__label { font-size: var(--t-label); opacity: .84; }
.hero__value { font-size: var(--t-display); font-weight: 750; letter-spacing: -.03em; margin-top: 2px; }
.hero__grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3);
  margin-top: var(--s5); position: relative; z-index: 1;
}
.hero__cell { background: rgba(255, 255, 255, .14); border-radius: var(--r-md); padding: var(--s3); }
.hero__cell b { display: block; font-size: 16px; font-weight: 650; margin-top: 2px; }
.hero__cell span { font-size: var(--t-cap); opacity: .85; display: flex; align-items: center; gap: 4px; }

.month-switch { display: flex; align-items: center; gap: 2px; background: rgba(255,255,255,.14); border-radius: var(--r-pill); padding: 2px; }
.month-switch button { width: 34px; height: 30px; display: grid; place-items: center; border-radius: var(--r-pill); color: #fff; }
.month-switch button:active { background: rgba(255,255,255,.22); }
.month-switch span { font-size: var(--t-label); font-weight: 600; min-width: 104px; text-align: center; text-transform: capitalize; }

/* ---------- прогресс ---------- */
.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress__fill { height: 100%; border-radius: var(--r-pill); background: var(--primary); transition: width var(--dur) var(--ease); }
.progress__fill--warn { background: var(--warning); }
.progress__fill--over { background: var(--danger); }
.progress__fill--ok { background: var(--success); }
.progress--sm { height: 6px; }

.card--list { padding: var(--s4); }

.budget-row { display: flex; flex-direction: column; gap: 6px; padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.budget-row:last-child { border-bottom: 0; padding-bottom: 0; }
.budget-row:first-child { padding-top: 0; }
.budget-row__top { display: flex; align-items: center; gap: var(--s3); }
.budget-row__name { flex: 1; min-width: 0; font-weight: 550; }
.budget-row__sum { font-size: var(--t-label); color: var(--text-2); font-variant-numeric: tabular-nums; }
.budget-row__bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }

/* ---------- списки ---------- */
.list { display: flex; flex-direction: column; }
.list--card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }

.tx {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}
.tx:last-child { border-bottom: 0; }
.tx:active { background: var(--surface-2); }
.tx__icon {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center; flex: none;
}
.tx__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx__title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx__sub { font-size: var(--t-label); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx__amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx__amount--income { color: var(--success); }

.day-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: var(--s3) var(--s1) var(--s1);
  font-size: var(--t-label); color: var(--text-2);
}
.day-head b { color: var(--text); font-weight: 600; }

.avatar {
  width: 40px; height: 40px; border-radius: var(--r-pill);
  display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: var(--t-label); color: #fff;
}

/* быстрые категории */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.quick__item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--s3) 4px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.quick__item:active { transform: scale(.96); background: var(--surface-3); }
.quick__item span { font-size: 11px; color: var(--text-2); text-align: center; line-height: 1.2; }

/* ---------- донат ---------- */
.donut { display: flex; align-items: center; gap: var(--s4); }
.donut__chart { position: relative; flex: none; }
.donut__center {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; pointer-events: none;
}
.donut__center b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.donut__center span { font-size: var(--t-cap); color: var(--text-2); }
.legend { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.legend__row { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-label); }
.legend__dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend__name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend__val { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- столбцы динамики ---------- */
.bars { display: flex; align-items: flex-end; gap: var(--s2); height: 132px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.bar { width: 11px; border-radius: 4px; min-height: 3px; transition: height var(--dur) var(--ease); }
.bar--expense { background: linear-gradient(180deg, var(--primary-2), var(--primary)); }
.bar--income { background: linear-gradient(180deg, #4BD69A, var(--success)); }
.bar-col span { font-size: 10px; color: var(--text-3); text-transform: capitalize; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s3); }
.tile span { font-size: var(--t-cap); color: var(--text-2); display: block; }
.tile b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; display: block; margin-top: 2px; white-space: nowrap; }
.tile b.pos { color: var(--success); }
.tile b.neg { color: var(--danger); }

/* ---------- формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--t-label); font-weight: 600; color: var(--text-2); }
.field__hint { font-size: var(--t-cap); color: var(--text-3); }
.field__error { font-size: var(--t-label); color: var(--danger); display: flex; align-items: center; gap: 4px; }

.input, .select, .amount-input {
  width: 100%; min-height: 48px;
  padding: 0 var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input:focus, .select:focus, .amount-input:focus {
  border-color: var(--primary); background: var(--surface);
  outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.input--error { border-color: var(--danger); }
.amount-wrap { position: relative; }
.amount-input {
  height: 62px; font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  padding-right: 46px; font-variant-numeric: tabular-nums;
}
.amount-wrap__cur {
  position: absolute; right: var(--s4); top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-weight: 600;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23666E7E' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px;
}

.segment {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-3); border-radius: var(--r-md);
}
.segment button {
  flex: 1; min-height: 42px; border-radius: 11px;
  font-weight: 600; font-size: var(--t-label); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segment--wrap { flex-wrap: wrap; }
.segment--wrap button { flex: 1 1 30%; }
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segment button[aria-pressed="true"].is-expense { color: var(--danger); }
.segment button[aria-pressed="true"].is-income { color: var(--success); }

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.chip {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: var(--s3) 6px; min-height: 76px; justify-content: center;
  border-radius: var(--r-md); border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.2;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chip .ic { opacity: .95; }
.chips--wide { grid-template-columns: repeat(4, 1fr); }

/* ---------- фильтр операций по участнику ---------- */
.member-filter {
  display: flex; gap: var(--s2);
  margin: 0 calc(-1 * var(--s4)); padding: 2px var(--s4);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.member-filter::-webkit-scrollbar { display: none; }
.member-chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 5px 11px 5px 6px; min-height: 38px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: var(--t-label); font-weight: 600; white-space: nowrap;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.member-chip:active { transform: scale(.97); }
.member-chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.member-chip--all { padding-left: 12px; }
.member-chip__count {
  padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-2);
  font-size: var(--t-cap); font-weight: 650; font-variant-numeric: tabular-nums;
}
.member-chip[aria-pressed="true"] .member-chip__count {
  background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary);
}

/* итоги по активному фильтру — над списком операций */
.filter-summary { display: flex; flex-direction: column; gap: 6px; padding: 0 var(--s1); }
.filter-summary__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.filter-summary__row .small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-summary__sums {
  display: flex; flex-wrap: wrap; gap: var(--s4);
  font-size: var(--t-label); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.filter-summary__sums b { font-weight: 650; }
.filter-summary__sums .exp { color: var(--text); }
.filter-summary__sums .inc { color: var(--success); }

/* Сетка выбора иконки категории: разделы по смыслу + прокрутка,
   чтобы библиотека иконок помещалась в нижний лист на любом экране */
.icon-picker {
  max-height: 42vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 2px; margin: -2px;
}
.icon-picker__group + .icon-picker__group { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); }
.icon-picker__title {
  font-size: var(--t-label); color: var(--text-2); font-weight: 550;
  margin-bottom: 8px; letter-spacing: .01em;
}
.icon-picker__current {
  position: sticky; bottom: 0; margin-top: var(--s3); padding: var(--s2) 0 2px;
  background: var(--surface); font-size: var(--t-label); color: var(--text-2);
}
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s2); }
.icon-grid button {
  aspect-ratio: 1; min-height: 44px; display: grid; place-items: center;
  border-radius: var(--r-md); border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .12s ease;
}
.icon-grid button:hover { border-color: var(--text-3); color: var(--text); }
.icon-grid button:active { transform: scale(.94); }
.icon-grid button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon-grid button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.color-grid { display: flex; flex-wrap: wrap; gap: var(--s2); }
.color-grid button {
  width: 34px; height: 34px; border-radius: var(--r-pill);
  border: 2px solid transparent; box-shadow: 0 0 0 1px var(--border) inset;
}
.color-grid button[aria-pressed="true"] { border-color: var(--text); transform: scale(1.06); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s3) 0;
}
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-row__text b { display: block; font-weight: 550; }
.switch-row__text span { font-size: var(--t-label); color: var(--text-2); }

/* ---------- таббар и FAB ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: center;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  border-top: 1px solid var(--border);
  z-index: 30;
}
.tab {
  flex: 1; height: var(--tab-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 10.5px; font-weight: 600;
  transition: color var(--dur) var(--ease);
}
.tab[aria-selected="true"] { color: var(--primary); }
.tab__slot {
  flex: 0 0 76px; position: relative;
  height: var(--tab-h);          /* слот той же высоты, что и табы — FAB считается от его центра */
  align-self: flex-end;          /* панель не «съезжает» из-за выступающей кнопки */
}
.fab {
  position: absolute; left: 50%; top: calc(50% - 10px);
  transform: translate(-50%, -50%);
  width: 56px; height: 56px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--hero-1), var(--hero-2));
  color: #fff; box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--primary) 70%, transparent);
  transition: transform var(--dur) var(--ease);
}
.fab:active { transform: translate(-50%, -50%) scale(.94); }

/* ---------- sheet ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.sheet-root.is-open { pointer-events: auto; }
.sheet__scrim {
  position: absolute; inset: 0; background: var(--scrim);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.sheet-root.is-open .sheet__scrim { opacity: 1; }
.sheet {
  position: absolute; bottom: 0; left: 50%;
  width: 100%; max-width: 480px;
  transform: translateX(-50%) translateY(102%);
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  max-height: 92dvh; display: flex; flex-direction: column;
  transition: transform .28s var(--ease);
}
.sheet-root.is-open .sheet { transform: translateX(-50%) translateY(0); }
.sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: var(--s3) auto 0; }
.sheet__head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4) var(--s2);
}
.sheet__title { flex: 1; font-size: var(--t-head); font-weight: 680; letter-spacing: -.01em; }
.sheet__body {
  padding: var(--s2) var(--s4) var(--s5);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s4);
  padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom));
}
.sheet__foot {
  padding: var(--s3) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex; gap: var(--s2);
}

/* ---------- пустые состояния и утилиты ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s2); padding: var(--s8) var(--s4);
}
.empty__icon {
  width: 64px; height: 64px; border-radius: 20px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  margin-bottom: var(--s2);
}
.empty h3 { font-size: var(--t-head); font-weight: 650; }
.empty p { color: var(--text-2); font-size: var(--t-label); max-width: 30ch; }
.empty__actions { display: flex; flex-direction: column; gap: var(--s2); width: 100%; max-width: 320px; margin-top: var(--s3); }

.toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + var(--s5) + env(safe-area-inset-bottom));
  z-index: 80; width: calc(100% - 32px); max-width: 420px;
  display: flex; flex-direction: column; gap: var(--s2); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--text); color: var(--bg);
  font-size: var(--t-label); font-weight: 550;
  box-shadow: var(--shadow-3);
  animation: toast-in .24s var(--ease);
}
.toast--error { background: var(--danger); color: #fff; }
.toast--success { background: var(--success); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.row { display: flex; align-items: center; gap: var(--s3); }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.small { font-size: var(--t-label); }
.tabnum { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--t-cap); font-weight: 650;
}
.pill--ok { background: var(--success-soft); color: var(--success); }
.pill--warn { background: var(--warning-soft); color: var(--warning); }
.pill--over { background: var(--danger-soft); color: var(--danger); }
.pill--neutral { background: var(--surface-3); color: var(--text-2); }

.search-wrap { position: relative; }
.search-wrap .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-wrap .input { padding-left: 42px; }

@media (min-width: 700px) {
  .app { min-height: 100dvh; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .tabbar { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
