/* Нижняя панель, форма операции и калькулятор */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 640px;
  margin: 0 auto;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
  transform: translateY(105%);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet.show { transform: none; }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin: 8px auto 4px; flex-shrink: 0; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(16px + var(--safe-b)); overscroll-behavior: contain; }
.sheet-title { font-size: 17px; font-weight: 600; text-align: center; margin: 2px 0 16px; letter-spacing: -.02em; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 14px; min-height: 30px; }
.sheet-head .sheet-title { margin: 0; }
.sheet-head button { color: var(--link); font-size: 17px; min-width: 64px; text-align: left; }
.sheet-head button:last-child { text-align: right; font-weight: 600; }

.field { background: var(--card); border-radius: 12px; margin-bottom: 10px; }
.field textarea { width: 100%; border: 0; outline: 0; background: none; padding: 4px 14px 10px; font-size: 16px; resize: none; min-height: 110px; }
.field label { display: block; font-size: 13px; color: var(--hint); padding: 8px 14px 0; }
.field input, .field select {
  width: 100%;
  border: 0;
  outline: 0;
  background: none;
  padding: 4px 14px 10px;
  font-size: 16px;
  appearance: none;
}
.field select:disabled { opacity: .6; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.emoji-row button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 22px;
  background: var(--card);
}
.emoji-row button.on { box-shadow: 0 0 0 2px var(--accent); }
.color-row { display: flex; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.color-row button { width: 30px; height: 30px; border-radius: 50%; background: var(--c); }
.color-row button.on { outline: 2px solid var(--text); outline-offset: 2px; }
.sheet-actions { display: grid; gap: 8px; margin-top: 14px; }

/* ---- форма операции ---- */
.ed-amount {
  text-align: center;
  padding: 10px 0 6px;
  cursor: pointer;
}
.ed-amount .expr { font-size: 14px; color: var(--hint); min-height: 18px; }
.ed-amount .value { font-size: 44px; font-weight: 700; letter-spacing: -.035em; line-height: 1.1; }
.ed-amount .value .cur { font-size: 24px; color: var(--hint); margin-left: 4px; font-weight: 600; }
.ed-amount.dim .value { color: var(--hint); }
.ed-amount.expense .value { color: var(--text); }
.ed-amount.income .value { color: var(--income); }
.ed-to {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.ed-to.target { outline: 2px solid var(--accent); }
.ed-to b { font-size: 18px; }

.ed-accounts { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.ed-acc {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border-radius: 12px;
  padding: 8px 10px;
  text-align: left;
}
.ed-acc .ico { width: 32px; height: 32px; font-size: 16px; }
.ed-acc small { display: block; font-size: 11px; color: var(--hint); }
.ed-acc span { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-arrow { color: var(--hint); flex-shrink: 0; }

.ed-cats {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  grid-auto-columns: 74px;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 2px 8px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.ed-cats::-webkit-scrollbar { display: none; }
.ed-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 2px;
  border-radius: 12px;
  scroll-snap-align: start;
}
.ed-cat span:last-child { max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-cat .ico { width: 46px; height: 46px; border-radius: 12px; font-size: 22px; transition: transform .15s; background: var(--card); }
.ed-cat.on .ico { background: var(--c); transform: scale(1.04); box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--c); }
.ed-cat small { font-size: 10px; color: var(--hint); margin-top: -3px; font-variant-numeric: tabular-nums; }
.ed-cat.on span:last-child { font-weight: 600; }
.ed-cat.new .ico { background: var(--fill); color: var(--link); font-size: 26px; font-weight: 300; }
.ed-newcat { display: flex; gap: 8px; margin-bottom: 8px; }
.ed-newcat input { flex: 1; border: 0; outline: 0; background: var(--card); border-radius: 12px; padding: 10px 12px; font-size: 16px; min-width: 0; }
.ed-newcat button { padding: 0 14px; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 600; }

.ed-meta { display: flex; gap: 8px; margin-bottom: 8px; }
.ed-comment {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
}
.ed-dates { display: flex; gap: 6px; margin-bottom: 10px; }
.ed-dates button, .ed-date-pick {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--card);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  white-space: nowrap;
}
.ed-dates .on { background: var(--accent); color: var(--accent-text); }
.ed-options { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.ed-options button { padding: 7px 12px; border-radius: 999px; background: var(--card); font-size: 13px; font-weight: 500; }
.ed-options button.on { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }
.ed-sms { font-size: 15px; color: var(--link); display: block; margin: 0 auto 6px; }
.ed-date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; }

.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.keypad button {
  height: 46px;
  border-radius: 10px;
  background: var(--card);
  font-size: 24px;
  font-weight: 400;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
  user-select: none;
  -webkit-user-select: none;
}
.keypad button:active { background: var(--fill); }
.keypad .op { color: var(--link); font-size: 24px; }
.ed-save { margin-top: 8px; }
.ed-delete { margin-top: 4px; }

.picker .row { background: var(--card); }
.picker .row.on .row-title { color: var(--link); font-weight: 600; }
