:root {
  color-scheme: light dark;

  /* surfaces */
  --bg: #f2f4f0;
  --card: #ffffff;
  --fill: #eef1ed;          /* input / quiet fills */
  --fill-strong: #e3e8e3;
  --hairline: rgba(40, 56, 48, 0.12);
  --shadow: 0 1px 2px rgba(30, 45, 38, 0.05), 0 6px 20px rgba(30, 45, 38, 0.05);

  /* text */
  --text: #17201b;
  --muted: #6a756f;
  --faint: #9aa49e;

  /* accent */
  --accent: #2c7a57;
  --accent-press: #246649;
  --accent-text: #ffffff;
  --accent-soft: #e4f1ea;
  --accent-soft-text: #1f6447;
  --ring: rgba(44, 122, 87, 0.35);

  /* status */
  --danger: #c4372c;
  --danger-soft: #fdecea;
  --danger-text: #a12a21;
  --swipe-delete: #d63b30;   /* solid fill behind white text */

  /* refunds (negative amounts) */
  --refund: #2f6fb3;

  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1210;
    --card: #191f1c;
    --fill: #222a26;
    --fill-strong: #2b3430;
    --hairline: rgba(220, 240, 230, 0.09);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px rgba(0, 0, 0, 0.25);

    --text: #eaefec;
    --muted: #9ba7a1;
    --faint: #6b7671;

    --accent: #4cb487;
    --accent-press: #3fa078;
    --accent-text: #08130e;
    --accent-soft: #1b3428;
    --accent-soft-text: #8fd9b6;
    --ring: rgba(76, 180, 135, 0.45);

    --danger: #ff7b6e;
    --danger-soft: #3a1f1c;
    --danger-text: #ffaba2;
    --swipe-delete: #c8382d;

    --refund: #7fb4ee;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.top, main {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
  padding-bottom: 12px;
}
h1.greeting { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; min-height: 1.15em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h1 { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }

.icon-btn {
  flex: none;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  margin-bottom: 2px;
  border: 0; border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: color .15s, transform .15s var(--ease);
}
.icon-btn:hover { color: var(--accent); }
.icon-btn:active { transform: scale(.94); }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
}
.view > * + * { margin-top: 12px; }

/* ---------- form controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { font-size: 17px; min-width: 0; }  /* >=16px avoids iOS zoom */

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  font-size: 17px; font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, transform .12s var(--ease), opacity .15s;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { background: var(--accent-press); }
.btn.primary:disabled:not(.loading) { opacity: .55; }
.btn.secondary { background: var(--fill-strong); color: var(--text); }
.btn.ghost { background: transparent; color: var(--accent); min-height: 44px; }

.spinner {
  display: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.4px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn.loading .spinner { display: block; }
.btn.loading { opacity: .9; }
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: 15px;
  line-height: 1.4;
  text-align: left;
  animation: rise .2s var(--ease);
}
.error::before {
  content: "!";
  flex: none;
  display: grid; place-items: center;
  width: 20px; height: 20px;
  margin-top: 0;
  border-radius: 50%;
  background: var(--danger);
  color: var(--card);
  font-size: 13px; font-weight: 800;
}

/* ---------- login / settings ---------- */
.auth {
  max-width: 400px;
  margin: max(6vh, 32px) auto 0;
  padding: 32px 20px 20px;
  text-align: center;
}
.app-icon {
  display: block;
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(44, 122, 87, 0.28);
}
.tagline { color: var(--muted); font-size: 15px; margin: 6px auto 24px; max-width: 30ch; }
.auth > * + .error, .auth > .stack { margin-top: 16px; }
.stack { display: grid; gap: 8px; }

.field-group {
  text-align: left;
  border-radius: var(--radius);
  background: var(--fill);
  overflow: hidden;
}
.field { display: block; padding: 10px 14px 8px; position: relative; }
.field + .field { box-shadow: 0 -1px 0 var(--hairline); }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.field input {
  display: block; width: 100%;
  padding: 2px 0 0;
  border: 0; background: transparent;
  font-size: 17px;
}
.field input::placeholder { color: var(--faint); }
.field:focus-within .field-label { color: var(--accent); }
.field input:focus-visible { outline: none; }

/* ---------- entry ---------- */
.composer { padding: 4px 4px 14px; transition: box-shadow .2s; }
.composer:focus-within { box-shadow: var(--shadow), 0 0 0 2px var(--ring); }
.composer textarea {
  display: block; width: 100%;
  min-height: 140px;
  padding: 14px 14px 8px;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 19px; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--faint); }
.composer textarea:focus-visible { outline: none; }
.hint { padding: 0 14px; font-size: 14px; line-height: 1.4; color: var(--faint); }
.example { color: var(--muted); }

.mic-hint {
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px;
  font-size: 14px; color: var(--muted);
}
.mic-hint svg { flex: none; color: var(--accent); }

/* ---------- review ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 4px 4px 0;
}
.count { font-size: 15px; color: var(--muted); }

.list { padding: 0; overflow: hidden; }
.row { animation: rise .22s var(--ease) both; }
.row-body { padding: 14px 16px 10px; }
.row + .row { box-shadow: 0 -1px 0 var(--hairline); }
.row-line { display: flex; align-items: center; gap: 8px; }
.row-sub { margin-top: 4px; }

/* inputs that read as text until focused */
.row input {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 6px 8px;
  transition: background-color .15s;
}
.row input:hover { background: var(--fill); }
.row input:focus { background: var(--fill); outline: none; box-shadow: 0 0 0 2px var(--ring); }
.row input::placeholder { color: var(--faint); }
.row input[aria-invalid="true"] { background: var(--danger-soft); color: var(--danger-text); }
.row input[aria-invalid="true"]::placeholder { color: var(--danger-text); opacity: .6; }

.pill {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  max-width: calc(100% - 150px);
  display: inline-flex; align-items: center;
  min-height: 34px;
  padding: 4px 30px 4px 12px;
  border-radius: 999px;
  background-color: var(--accent-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237d8a84' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: var(--accent-soft-text);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.cat-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill select {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}
.pill:focus-within { box-shadow: 0 0 0 2px var(--ring); }

.f-amount {
  flex: 1 1 auto;
  width: 0;
  margin-right: -6px;
  text-align: right;
  font-size: 22px !important;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
/* euro sign after the amount */
.cur {
  flex: none;
  margin-left: -4px;
  color: var(--muted);
  font-size: 20px; font-weight: 700; line-height: 1;
}

.f-note {
  flex: 1 1 auto;
  width: 0;
  margin-left: -8px;
  font-size: 16px;
  color: var(--muted);
}
.f-note:focus { color: var(--text); }

.date-chip {
  position: relative;
  flex: none;
  display: inline-flex; align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--fill);
  color: var(--muted);
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.date-chip:focus-within { box-shadow: 0 0 0 2px var(--ring); color: var(--text); }
.date-chip input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  padding: 0; margin: 0;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}
.date-chip input:hover, .date-chip input:focus { box-shadow: none; }
.date-chip.invalid { background: var(--danger-soft); color: var(--danger-text); }


.add-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  box-shadow: 0 -1px 0 var(--hairline);
  background: transparent;
  color: var(--accent);
  font-size: 17px; font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.add-row:hover { background: var(--fill); }
.add-row:focus-visible { outline-offset: -3px; }
.add-icon {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 18px; font-weight: 600; line-height: 1;
}
#rows:empty + .add-row { box-shadow: none; }

.total-card {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 20px;
}
.total-card > span { color: var(--muted); font-size: 17px; font-weight: 500; }
.total-card strong {
  min-width: 0;
  text-align: right;
  font-size: 30px; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.total-card { gap: 12px; }

.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex; gap: 10px;
  padding: 12px calc(var(--gutter) + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  box-shadow: 0 -1px 0 var(--hairline);
  animation: slide-up .3s var(--ease) both;
}
.action-bar { flex-wrap: wrap; }
.action-bar .error { flex: 1 1 100%; }
.action-bar .secondary { flex: 1 1 0; }
.action-bar .primary { flex: 2 1 0; }
#review { padding-bottom: 76px; }
#review:has(#save-error:not([hidden])) { padding-bottom: 150px; }

@media (min-width: 700px) {
  .top { padding-top: 48px; }
  .action-bar {
    position: sticky;
    margin-top: 16px;
    padding: 12px 0 24px;
    box-shadow: none;
    background: linear-gradient(to bottom, transparent, var(--bg) 30%);
    -webkit-backdrop-filter: none; backdrop-filter: none;
    animation: none;
  }
  #review, #review:has(#save-error:not([hidden])) { padding-bottom: 0; }
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  transform: translate(-50%, -150%);
  opacity: 0;
}
.toast.show { animation: toast 2.2s var(--ease) both; }
@keyframes toast {
  0% { transform: translate(-50%, -150%); opacity: 0; }
  12%, 85% { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -150%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .toast.show { animation: none; transform: translate(-50%, 0); opacity: 1; }
}

/* ---------- refunds ---------- */
.neg { color: var(--refund) !important; }

/* ---------- recent (last 30 days) ---------- */
.recent { margin-top: 20px; }
.recent-note-line { display: flex; align-items: baseline; gap: 10px; padding: 0 4px; }
.recent-note { font-size: 14px; color: var(--muted); }
.recent-note::before { content: "⚠︎ "; color: var(--danger); }
.link-btn {
  border: 0; padding: 4px 0; background: none;
  color: var(--accent); font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.recent-empty { padding: 8px 4px; font-size: 15px; color: var(--faint); }

.recent-group + .recent-group { margin-top: 18px; }
.recent-day {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 4px 8px;
}
.recent-day h3 {
  margin: 0;
  font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted);
}
.recent-subtotal { text-align: right; font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.recent-list { list-style: none; margin: 0; padding: 0; overflow: hidden; }

.recent-row + .recent-row { box-shadow: 0 -1px 0 var(--hairline); }
.recent-content {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  user-select: none; -webkit-user-select: none;
  cursor: pointer;
}
.recent-content:focus-visible { outline-offset: -3px; }
@media (hover: hover) and (pointer: fine) {
  .recent-row:not(.open):not(.pending) .recent-content:hover { background: color-mix(in srgb, var(--fill) 55%, var(--card)); }
}
.recent-row:not(.open):not(.pending) .recent-content:active { background: var(--fill); }

/* Swipe to delete (review rows and the recent list): a red "Удалить" action
   with the content sliding over it. */
.swipe-row {
  position: relative;
  overflow: hidden;
  transition: height .28s var(--ease), opacity .28s var(--ease);
}
.swipe-row.collapse { animation: none; opacity: 0; }
.swipe-content {
  position: relative;
  background: var(--card);
  touch-action: pan-y;          /* vertical scroll stays native; we handle horizontal */
  transition: transform .28s var(--ease), opacity .2s;
}
.swipe-row.dragging .swipe-content { transition: none; }
.swipe-row.pending .swipe-content { opacity: .55; }
.swipe-action {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 88px;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 18px;
  border: 0;
  background: var(--swipe-delete);
  color: #fff;
  font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: width .28s var(--ease);
}
.swipe-row.dragging .swipe-action { transition: none; }
.swipe-row.armed .swipe-action { justify-content: flex-start; }
.swipe-row:not(.open):not(.dragging) .swipe-action { visibility: hidden; }
.swipe-row.pending .swipe-action { cursor: progress; }
.swipe-row.pending .swipe-action { justify-content: center; }
.swipe-row.pending .swipe-label { font-size: 0; }   /* spinner only; the row is aria-busy */
.swipe-row.pending .swipe-label::before {
  content: ""; display: block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: spin .8s linear infinite;
}
.swipe-action:focus-visible { outline: 3px solid var(--ring); outline-offset: -3px; }
.row-error {
  margin: 0; padding: 0 16px 10px 64px;
  background: var(--card);
  font-size: 13px; color: var(--danger-text);
}
.row-error::before { content: "⚠︎ "; color: var(--danger); }

/* Desktop: a small trash button on hover that reveals the action. On touch screens
   swipe instead: in the recent list it stays for screen readers only, and review rows
   (where it sat next to the date chip and stole taps) drop it. */
.row-trash {
  flex: none;
  display: grid; place-items: center;
  width: 32px; height: 32px; margin: 0 -8px 0 -4px;
  border: 0; border-radius: 9px;
  background: none; color: var(--faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s, background-color .15s;
}
.swipe-row:hover .row-trash, .row-trash:focus-visible { opacity: 1; }
.row-trash:hover, .row-trash:focus-visible { color: var(--danger); background: var(--danger-soft); }
.swipe-row.open .row-trash, .swipe-row.pending .row-trash { visibility: hidden; }
.row .row-trash { width: 36px; height: 36px; margin: 0 -8px 0 8px; } /* clear of the date chip */
@media not all and (hover: hover) and (pointer: fine) {
  .row-trash {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .row .row-trash { display: none; }
}
.recent-emoji {
  flex: none;
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 19px;
}
.recent-main { flex: 1; min-width: 0; }
.recent-title { display: block; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; min-width: 0; }
.mini-pill {
  min-width: 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; max-width: 40%; }
.recent-amount { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.recent-author { font-size: 12px; color: var(--faint); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.skeleton {
  height: 60px;
  border-radius: var(--radius);
  background: var(--fill);
  opacity: .7;
  animation: pulse 1.4s ease-in-out infinite;
}
.skeleton + .skeleton { margin-top: 8px; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- tabs (segmented control under the greeting) ---------- */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin: 0 0 16px;
  padding: 2px;
  border-radius: 11px;
  background: var(--fill-strong);
}
.tab {
  min-height: 34px;
  border: 0; border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .2s var(--ease), color .2s, box-shadow .2s;
}
.tab[aria-selected="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 0 0 .5px var(--hairline);
}
.tab:focus-visible { outline-offset: 0; }

/* ---------- edit sheet: bottom sheet on phones, centered dialog on wide screens ---------- */
.sheet {
  width: 100%; max-width: 100%;
  max-height: 100%;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.sheet::backdrop {
  background: rgba(8, 14, 11, .38);
  animation: fade .22s var(--ease);
}
.sheet-panel {
  max-height: calc(100dvh - env(safe-area-inset-top) - 12px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px calc(var(--gutter) + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .18);
  animation: sheet-up .32s var(--ease) both;
}
.sheet-panel:focus { outline: none; }
.sheet.closing .sheet-panel { animation: sheet-down .18s ease-in both; }
.sheet.closing::backdrop { opacity: 0; transition: opacity .18s; }
.sheet-grabber {
  width: 36px; height: 5px;
  margin: 0 auto 12px;
  border-radius: 3px;
  background: var(--fill-strong);
}
.sheet h2 { margin: 0 4px 14px; font-size: 20px; }
.sheet .field-group { background: var(--card); box-shadow: var(--shadow); }
.sheet .field input, .sheet .field select { min-height: 30px; }
.sheet input:disabled, .sheet select:disabled { opacity: .6; }
#edit-amount { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet .field input[aria-invalid="true"] { color: var(--danger-text); }
.sheet .field:has([aria-invalid="true"]) { background: var(--danger-soft); }
.sheet .field:has([aria-invalid="true"]) .field-label { color: var(--danger-text); }
.field-select select {
  display: block; width: 100%;
  padding: 2px 22px 0 0; margin: 0;
  border: 0; background: transparent;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237d8a84' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  cursor: pointer;
}
.field-select select:focus-visible { outline: none; }
.field-hint { margin: 8px 4px 0; font-size: 13px; color: var(--faint); }
.sheet .error { margin-top: 12px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .secondary { flex: 1 1 0; }
.sheet-actions .primary { flex: 2 1 0; }
.danger-link {
  display: block;
  margin: 8px auto 0;
  min-height: 44px; padding: 0 16px;
  color: var(--danger); font-size: 16px;
}
.danger-link:disabled { opacity: .5; cursor: default; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes pop-out { to { opacity: 0; transform: scale(.96); } }

@media (min-width: 700px) {
  .sheet { width: 440px; margin: auto; }
  .sheet-panel {
    max-height: calc(100dvh - 48px);
    padding: 22px 22px 14px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    animation-name: pop-in;
    animation-duration: .22s;
  }
  .sheet.closing .sheet-panel { animation-name: pop-out; }
  .sheet-grabber { display: none; }
}

/* ---------- summary (Итоги) ---------- */
.summary { animation: rise .28s var(--ease) both; }
.month-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 14px;
}
.month-switch h2 { flex: 1; text-align: center; font-size: 20px; }
.month-btn { width: 40px; height: 40px; margin: 0; color: var(--accent); }
.month-btn:disabled { color: var(--faint); opacity: .45; box-shadow: none; cursor: default; }
.month-btn:disabled:active { transform: none; }
.month-btn[aria-disabled="true"] { cursor: progress; }

#summary-body[aria-busy="true"] > .card { opacity: .6; transition: opacity .2s; }
.sum-hero { display: flex; flex-direction: column; align-items: flex-start; padding: 18px 20px; }
.sum-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sum-total { margin-top: 2px; font-size: 36px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sum-count { margin-top: 2px; font-size: 15px; color: var(--muted); }

.sum-list { list-style: none; margin: 12px 0 0; padding: 0; overflow: hidden; }
.sum-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.sum-row + .sum-row { box-shadow: 0 -1px 0 var(--hairline); }
.sum-main { flex: 1; min-width: 0; }
.sum-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sum-name { min-width: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-amount { flex: none; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum-sub { align-items: center; margin-top: 6px; }
.sum-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.sum-fill { display: block; height: 100%; border-radius: 2px; background: var(--accent); transition: width .4s var(--ease); }
.sum-pct { flex: none; min-width: 3.4em; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.sum-empty, .sum-error { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 20px; text-align: center; color: var(--muted); font-size: 15px; }
.sum-empty-icon { font-size: 32px; line-height: 1; opacity: .8; }
.sum-error p::before { content: "⚠︎ "; color: var(--danger); }
.sum-skel-hero { height: 108px; }
.sum-skel-list { height: 236px; margin-top: 12px; }

/* ---------- motion ---------- */
.view, .auth { animation: rise .28s var(--ease) both; }
#review { animation-name: fade; } /* no transform: it would anchor the fixed action bar */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .spinner, .swipe-row.pending .swipe-label::before { animation: spin 1.5s linear infinite !important; }
}
