/* Кнопки, чипы, поля, списки операций, шторки, тосты, пустые состояния. */

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px;
  font-size: 14.5px; font-weight: 600; color: var(--text);
  background: var(--fill); border: 1px solid transparent;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { color: #fff; background: linear-gradient(140deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 18px -10px var(--accent); }
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(140deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { color: var(--expense); background: color-mix(in srgb, var(--expense) 12%, transparent); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 12px; background: var(--glass-soft); border: 1px solid var(--glass-edge); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon.btn-xs { width: 28px; height: 28px; border-radius: 9px; }
.btn-icon.btn-xs svg { width: 14px; height: 14px; }

/* Наблюдения: тон плитки по важности. */
.tile.warn { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 45%, transparent); }
.tile.danger { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--expense) 45%, transparent); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }

/* ---------- Чипы / сегменты ---------- */
.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-2);
  background: var(--glass-soft); border: 1px solid var(--glass-edge);
  transition: all var(--dur) var(--ease);
}
.chip svg { width: 14px; height: 14px; }
.chip.active { color: #fff; background: linear-gradient(140deg, var(--accent), var(--accent-2)); border-color: transparent; }
.chip.active svg { color: #fff; }

.segment { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--fill); }
.segment button {
  padding: 7px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: all var(--dur) var(--ease);
}
.segment button.active { background: var(--glass-strong); color: var(--text); box-shadow: 0 2px 8px -4px rgba(0,0,0,.25); }

/* ---------- Поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-3); padding-left: 2px; }
.input, .select, textarea.input {
  height: 44px; padding: 0 13px; border-radius: 12px; width: 100%;
  background: var(--glass-soft); border: 1px solid var(--glass-edge); color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
textarea.input { height: auto; padding: 11px 13px; resize: vertical; min-height: 76px; }
.input:focus, .select:focus { border-color: var(--accent); background: var(--glass-strong); outline: none; }
.input::placeholder { color: var(--text-3); }
.select { appearance: none; background-image: none; }
.input-lg { height: 56px; font-size: 26px; font-weight: 700; font-family: var(--font-num); letter-spacing: -0.02em; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill-2); transition: background var(--dur) var(--ease); }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform var(--dur) var(--ease);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }
.search .input { padding-left: 38px; }

/* ---------- Списки ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px; width: 100%; text-align: left;
  border-radius: 12px; transition: background var(--dur) var(--ease);
}
.list-row:hover { background: var(--fill); }
.list-row + .list-row { box-shadow: inset 0 1px 0 var(--line); }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px 4px; font-size: 12.5px; font-weight: 650; color: var(--text-3); }

.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
}
.avatar svg { width: 19px; height: 19px; }
.avatar-sm { width: 30px; height: 30px; border-radius: 10px; }
.avatar-sm svg { width: 15px; height: 15px; }

/* Логотип банка: плитка приложения во всю ячейку. Сами файлы уже приведены к одному
   квадрату (scripts/logos.py), поэтому здесь ни полей, ни масштабирования не нужно. */
.avatar.logo {
  position: relative;
  background: #fff;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.avatar.logo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
/* Значок «перевод/обмен» поверх логотипа. */
.avatar.logo .badge-kind {
  position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; background: var(--neutral); color: #fff; border: 1.5px solid var(--glass-strong);
}
.avatar.logo .badge-kind svg { width: 10px; height: 10px; }

.amount { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.amount-lg { font-size: 34px; font-weight: 760; letter-spacing: -0.035em; }
.amount-xl { font-size: 42px; font-weight: 780; letter-spacing: -0.04em; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--fill); color: var(--text-2); }
.pill svg { width: 12px; height: 12px; }
.pill-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Шторка / модалка ----------
   Телефон: лист снизу с ручкой. Большой экран: окно по центру.
   Скроллится только тело — шапка и кнопки всегда на виду. */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 10, 16, 0.5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 160ms var(--ease);
}
.sheet-backdrop.closing { animation: fade-out 150ms var(--ease) forwards; }
.sheet-backdrop.closing .sheet { animation: sheet-down 150ms var(--ease) forwards; }

.sheet {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; max-width: 540px; max-height: min(92vh, 900px);
  overflow: hidden; overscroll-behavior: contain;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -12px 48px rgba(8, 10, 16, 0.32);
  animation: sheet-up 280ms cubic-bezier(0.22, 1, 0.36, 1);
  transition: transform 180ms var(--ease);
}
.sheet-wide { max-width: 760px; }

@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-down { to { transform: translateY(24px); opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.sheet-grip {
  flex: none; height: 22px; display: grid; place-items: center; cursor: grab; touch-action: none;
}
.sheet-grip::before { content: ""; width: 40px; height: 4px; border-radius: 999px; background: var(--fill-2); }

.sheet-head {
  flex: none; display: flex; align-items: flex-start; gap: 12px;
  padding: 2px 20px 14px;
}
.sheet-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.sheet-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; line-height: 1.35; }
.sheet-close {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fill); color: var(--text-2); border: none; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sheet-close:hover { background: var(--fill-2); color: var(--text); }
.sheet-close svg { width: 17px; height: 17px; }

.sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 20px 18px;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 10px);
          mask-image: linear-gradient(180deg, transparent 0, #000 10px);
}
.sheet-body > :first-child { margin-top: 0; }

.sheet-foot {
  flex: none; padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--glass-edge);
  background: var(--glass-strong);
}
.sheet-foot .btn { height: 48px; }

@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet {
    border-radius: var(--radius-xl); max-height: min(86vh, 860px);
    box-shadow: 0 24px 64px rgba(8, 10, 16, 0.38);
    animation: sheet-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 18px; }
  @keyframes sheet-in { from { transform: scale(0.97) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Содержимое шторки: шапка операции, пары «поле — значение», секции. */
.sheet-hero { display: flex; align-items: center; gap: 12px; padding: 4px 0 2px; }
.sheet-hero-title { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.sheet-hero .amount-lg { margin-left: auto; white-space: nowrap; }

.kv { display: flex; flex-direction: column; border-radius: var(--radius-md); background: var(--fill); overflow: hidden; }
.kv-row { display: flex; align-items: baseline; gap: 14px; padding: 10px 14px; font-size: 13.5px; }
.kv-row + .kv-row { border-top: 1px solid var(--glass-edge); }
.kv-row dt { color: var(--text-3); flex: none; }
.kv-row dd { margin: 0; margin-left: auto; text-align: right; font-weight: 550; overflow-wrap: anywhere; }

.sheet-section { margin-top: 20px; }
.sheet-label { font-size: 12.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }

.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.btn-ghost.danger { color: var(--expense); }
.btn-ghost.danger:hover { background: color-mix(in srgb, var(--expense) 12%, transparent); }

/* ---------- Тосты ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 22px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; padding: 10px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  animation: fade-in 180ms var(--ease); max-width: min(92vw, 460px);
}
.toast.error { color: var(--expense); }
.toast.ok { color: var(--income); }
@media (min-width: 980px) { .toasts { bottom: 26px; } }

/* ---------- Пустые состояния и загрузка ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 34px 16px; text-align: center; color: var(--text-3); }
.empty svg { width: 30px; height: 30px; opacity: 0.6; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--fill-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Прогресс-полоски ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
