/* ── Global: ensure [hidden] always wins over author display rules ─ */
[hidden] { display: none !important; }

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --bg:           var(--tg-theme-bg-color,           #ffffff);
  --text:         var(--tg-theme-text-color,         #000000);
  --hint:         var(--tg-theme-hint-color,         #888888);
  --button:       var(--tg-theme-button-color,       #2481cc);
  --button-text:  var(--tg-theme-button-text-color,  #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f4);
  --nav-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --income:   #31a24c;
  --expense:  #e53935;
  --transfer: #888888;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--secondary-bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }

/* ── Auth screen ───────────────────────────────────────────────── */
#auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  text-align: center;
  max-width: 320px;
  width: 100%;
}
.auth-icon { font-size: 56px; margin-bottom: 16px; }
.auth-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.auth-sub  { color: var(--hint); font-size: 14px; margin-bottom: 24px; }
.auth-widget-wrap { display: flex; justify-content: center; min-height: 44px; margin-top: 4px; }
.auth-btn {
  margin-top: 16px;
  padding: 10px 24px;
  background: var(--button);
  color: var(--button-text);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

/* ── App shell ─────────────────────────────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--secondary-bg);
  position: relative;
}

#screen {
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
}

/* ── Bottom nav ────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg);
  border-top: 1px solid rgba(0,0,0,0.08);
  display: flex;
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--hint);
  font-size: 10px;
  padding-top: 6px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.nav-item.active { color: var(--button); }
.nav-icon { font-size: 24px; line-height: 1; }
.nav-label { font-size: 10px; }

/* Badge on nav */
.nav-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 8px;
  min-width: 16px;
  height: 16px;
  background: var(--expense);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.nav-badge:empty { display: none; }

/* ── FAB ───────────────────────────────────────────────────────── */
#fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  right: max(16px, calc(50vw - 240px + 16px));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--button);
  color: var(--button-text);
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 3px 14px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s, box-shadow .12s;
}
#fab:active { transform: scale(0.92); box-shadow: 0 1px 6px rgba(0,0,0,0.18); }

/* ── FAB modal overlay ─────────────────────────────────────────── */
.fab-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(var(--safe-b) + 0px);
  -webkit-tap-highlight-color: transparent;
}
.fab-modal-card {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 540px;
  padding-bottom: calc(var(--safe-b) + 8px);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  animation: fab-slide-up .22s cubic-bezier(.32,.72,0,1);
}
@keyframes fab-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.fab-modal-header {
  display: flex;
  align-items: center;
  padding: 16px 16px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.07);
}
.fab-modal-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}
.fab-modal-close {
  padding: 4px 8px;
  font-size: 16px;
  color: var(--hint);
  background: none;
  border: none;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.fab-modal-body { padding: 12px 16px 4px; }
.fab-field-label {
  display: block;
  font-size: 11px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  margin-bottom: 4px;
  margin-top: 12px;
}
.fab-field-label:first-child { margin-top: 0; }
.fab-field-label-row { display: flex; align-items: center; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); }
.fab-field-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--secondary-bg);
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  min-height: 44px;
}
.fab-field-input:focus { box-shadow: 0 0 0 2px var(--button); }
.fab-field-select {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--secondary-bg);
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  min-height: 44px;
  cursor: pointer;
}
.fab-modal-footer { padding: 12px 16px 4px; }
.fab-submit-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--button);
  color: var(--button-text);
  border-radius: 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  min-height: 50px;
  -webkit-tap-highlight-color: transparent;
}
.fab-submit-btn:disabled { opacity: .5; cursor: default; }
.fab-submit-btn:not(:disabled):active { opacity: .85; }

/* ── Spinner / Loading ─────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--secondary-bg);
  border-top-color: var(--button);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--nav-h) - var(--safe-b) - 80px);
  color: var(--hint);
  font-size: 14px;
  gap: 12px;
}

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
}
.error-page .error-icon { font-size: 48px; }
.error-page p { color: var(--hint); font-size: 14px; }
.error-page button {
  margin-top: 8px;
  padding: 10px 24px;
  background: var(--button);
  color: var(--button-text);
  border-radius: 20px;
  font-size: 14px;
}

/* ── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border-radius: 14px;
  padding: 16px;
  margin: 8px 12px;
}

/* ── Section ───────────────────────────────────────────────────── */
.section {
  margin: 8px 0;
}
.section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 12px 16px 6px;
}
.section-list {
  background: var(--bg);
  border-radius: 14px;
  margin: 0 12px;
  overflow: hidden;
}
.section-footer {
  text-align: center;
  padding: 12px;
  color: var(--button);
  font-size: 13px;
  cursor: pointer;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ── Page header ───────────────────────────────────────────────── */
.page-header {
  background: var(--bg);
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.page-title { font-size: 18px; font-weight: 700; flex: 1; }
.back-btn {
  color: var(--button);
  font-size: 24px;
  width: 32px;
  display: flex;
  align-items: center;
}
.back-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-height: 44px;
  padding: 0;
  cursor: pointer;
  color: var(--button);
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  touch-action: manipulation;
}
.back-nav-arrow { font-size: 28px; line-height: 1; }
.back-nav-label { font-size: 18px; font-weight: 700; }

/* ── "Доступно сейчас" card ────────────────────────────────────── */
.available-now {
  margin-top: 12px;
}
.available-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.available-amounts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.available-amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.5px;
}
.available-amount-sm {
  font-size: 20px;
  font-weight: 600;
}
.available-empty {
  font-size: 22px;
  color: var(--hint);
}
.available-note {
  font-size: 11px;
  color: var(--hint);
  line-height: 1.4;
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 8px;
  margin-top: 4px;
}

/* ── Alert card ────────────────────────────────────────────────── */
.alert-card {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 14px 16px;
  color: var(--text);
}
.alert-card .alert-icon { font-size: 20px; }
.alert-card .alert-text { flex: 1; font-size: 14px; }
.alert-card .arrow { color: var(--hint); font-size: 18px; }

/* ── Transaction row ───────────────────────────────────────────── */
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.tx-row:active { background: rgba(0,0,0,0.04); }
.tx-row + .tx-row { border-top: 1px solid rgba(0,0,0,0.06); }

.tx-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.tx-icon.income   { background: rgba(49,162,76,.12); color: var(--income); }
.tx-icon.expense  { background: rgba(229,57,53,.1);  color: var(--expense); }
.tx-icon.transfer { background: rgba(0,0,0,.06);     color: var(--hint); }

.tx-info { flex: 1; min-width: 0; }
.tx-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta { font-size: 12px; color: var(--hint); margin-top: 2px; }

.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-size: 14px; font-weight: 600; }
.tx-amount.income   { color: var(--income); }
.tx-amount.expense  { color: var(--expense); }
.tx-amount.transfer { color: var(--hint); }
.tx-currency { font-size: 11px; color: var(--hint); }

/* ── Status badge ──────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.status-badge.needs_review  { background: rgba(255,152,0,.15); color: #e65100; }
.status-badge.confirmed     { background: rgba(49,162,76,.12); color: var(--income); }
.status-badge.uncategorized { background: rgba(0,0,0,.08); color: var(--hint); }
.status-badge.duplicate     { background: rgba(229,57,53,.1); color: var(--expense); }

/* ── Filter chips ──────────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  padding: 10px 12px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  background: var(--bg);
  color: var(--hint);
  border: 1px solid rgba(0,0,0,0.1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.active {
  background: var(--button);
  color: var(--button-text);
  border-color: var(--button);
}

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--hint);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* ── Timeline ──────────────────────────────────────────────────── */
.tl-day { margin-bottom: 16px; }
.tl-day-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px 4px;
  flex-wrap: wrap;
}
.tl-day-label  { font-size: 13px; font-weight: 600; color: var(--text); }
.tl-day-totals { font-size: 12px; color: var(--hint); }
.tl-day-rows   { margin: 0 12px; }

/* Period button in page-header */
.tl-period-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--hint);
  background: none;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tl-period-btn:active { opacity: .7; }

/* Period picker panel */
.tl-period-panel-inner {
  padding: 10px 16px 14px;
  background: var(--bg);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.tl-period-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tl-period-lbl  { font-size: 13px; color: var(--hint); width: 24px; flex-shrink: 0; }
.tl-date-inp    { flex: 1; }
.tl-period-actions { display: flex; gap: 8px; margin-top: 4px; }

/* Active period indicator */
.tl-active-period {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--button);
  background: var(--bg);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.tl-active-period span { flex: 1; }
.tl-clear-period {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--hint);
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

/* Load-more fallback (no IntersectionObserver) */
.tl-load-more { text-align: center; padding: 16px; }

/* ── Project row ───────────────────────────────────────────────── */
.project-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.project-row + .project-row { border-top: 1px solid rgba(0,0,0,0.06); }
.project-row:active { background: rgba(0,0,0,0.04); }
.project-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--button);
  flex-shrink: 0;
}
.project-name { flex: 1; font-size: 15px; font-weight: 500; }
.project-meta { font-size: 12px; color: var(--hint); }
.project-arrow { color: var(--hint); font-size: 18px; }

/* ── Account row ───────────────────────────────────────────────── */
.account-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.account-row + .account-row { border-top: 1px solid rgba(0,0,0,0.06); }
.account-row:active { background: rgba(0,0,0,0.04); }
.account-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--secondary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta { font-size: 12px; color: var(--hint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-right { text-align: right; flex-shrink: 0; }
.account-balance { font-size: 14px; font-weight: 600; }
.account-balance.positive { color: var(--income); }
.account-balance.negative { color: var(--expense); }
.account-currency { font-size: 12px; color: var(--hint); }

/* ── Detail block ──────────────────────────────────────────────── */
.detail-amount-block {
  text-align: center;
  padding: 28px 16px 20px;
  background: var(--bg);
  margin-bottom: 8px;
}
.detail-amount {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
}
.detail-amount.income   { color: var(--income); }
.detail-amount.expense  { color: var(--expense); }
.detail-type { font-size: 13px; color: var(--hint); margin-top: 4px; }

.detail-rows { background: var(--bg); border-radius: 14px; margin: 0 12px 8px; overflow: hidden; }
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
}
.detail-row + .detail-row { border-top: 1px solid rgba(0,0,0,0.06); }
.detail-key { width: 100px; flex-shrink: 0; font-size: 13px; color: var(--hint); }
.detail-val { flex: 1; font-size: 14px; }

/* ── Form ──────────────────────────────────────────────────────── */
.form-group { margin: 0 12px 8px; }
.form-label { font-size: 12px; color: var(--hint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 10px 0 6px; display: block; }
.form-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--button); }

.type-toggle {
  display: flex;
  gap: 8px;
  margin: 12px 12px 0;
}
.type-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg);
  color: var(--hint);
  border: 1px solid rgba(0,0,0,0.1);
  transition: background .15s, color .15s, border-color .15s;
}
.type-btn.income.active  { background: rgba(49,162,76,.12);  color: var(--income);  border-color: var(--income); }
.type-btn.expense.active { background: rgba(229,57,53,.1);   color: var(--expense); border-color: var(--expense); }

.submit-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 16px 12px;
  padding: 15px;
  background: var(--button);
  color: var(--button-text);
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}
.submit-btn:disabled { opacity: .5; cursor: default; }
.submit-btn:not(:disabled):active { transform: scale(0.98); }

/* ── More screen ───────────────────────────────────────────────── */
.menu-list { background: var(--bg); border-radius: 14px; margin: 0 12px; overflow: hidden; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.menu-item + .menu-item { border-top: 1px solid rgba(0,0,0,0.06); }
.menu-item:active { background: rgba(0,0,0,0.04); }
.menu-icon { font-size: 20px; width: 28px; text-align: center; }
.menu-label { flex: 1; font-size: 15px; }
.menu-arrow { color: var(--hint); font-size: 16px; }
.menu-item.danger .menu-label { color: var(--expense); }
.cat-list { background: var(--bg); border-radius: 14px; margin: 0 12px; overflow: hidden; }
.cat-parent-row { display: flex; align-items: center; gap: 12px; padding: 11px 8px 11px 16px; border-top: 1px solid rgba(0,0,0,0.06); }
.cat-parent-row:first-child { border-top: none; }
.cat-parent-name { font-size: 15px; flex: 1; }
.cp-row { min-height: 44px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cp-row:active { background: rgba(0,0,0,0.05); }
.cp-row-chevron { flex-shrink: 0; font-size: 18px; color: var(--hint); padding-right: 4px; line-height: 1; }
.cat-subs-block { padding: 0 8px 8px 56px; }
.cat-sub-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.cat-sub-item + .cat-sub-item { border-top: 1px solid rgba(0,0,0,0.04); }
.cat-sub-name { font-size: 13px; color: var(--hint); }
.cat-row-actions { display: flex; gap: 0; flex-shrink: 0; }
.cat-action-btn { background: none; border: none; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; color: var(--hint); -webkit-tap-highlight-color: transparent; }
.cat-action-btn:active { background: rgba(0,0,0,0.07); }
.cat-row--hidden { opacity: .5; }
.cat-hidden-badge { font-size: 11px; color: var(--hint); background: rgba(0,0,0,0.06); border-radius: 6px; padding: 1px 5px; margin-left: 4px; }
.page-hdr-btn { background: none; border: none; color: var(--button); font: inherit; font-size: 15px; padding: 8px 0 8px 8px; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.page-hdr-btn:active { opacity: .7; }
.cats-tabs { display: flex; gap: 2px; margin: 8px 12px 4px; background: rgba(0,0,0,0.06); border-radius: 10px; padding: 2px; }
.cats-tab { flex: 1; text-align: center; padding: 7px 4px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--hint); -webkit-tap-highlight-color: transparent; }
.cats-tab.active { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.cats-set-chips { padding: 8px 12px 0; }
.cats-arrow { font-size: 11px; color: var(--hint); flex-shrink: 0; cursor: pointer; padding: 4px 2px; }
.cats-sub-count { font-size: 12px; color: var(--hint); font-weight: 400; }
.cats-sub-row { font-size: 14px; color: var(--text); }
.cats-subs-open { background: rgba(0,0,0,.02); border-radius: 0 0 10px 10px; margin: 0 0 2px; }
.cats-add-sub { font-size: 13px; color: var(--button); padding: 6px 0 4px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cats-add-sub:active { opacity: .7; }
.cats-gear-btn { background: none; border: none; font-size: 18px; line-height: 1; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 8px; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
.cats-gear-btn:active { background: rgba(0,0,0,.07); }
.set-action-row { display: flex; align-items: center; gap: 10px; padding: 14px 20px; font-size: 16px; cursor: pointer; border-top: 1px solid rgba(0,0,0,.06); -webkit-tap-highlight-color: transparent; }
.set-action-row:first-child { border-top: none; }
.set-action-row:active { background: rgba(0,0,0,.04); }
.set-action-danger { color: var(--expense); }
.cp-notes-hint { font-size: 12px; color: var(--hint); margin-right: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px; }
.cp-delete-btn { display: block; width: 100%; margin-top: 8px; padding: 12px; background: none; border: none; color: var(--expense); font: inherit; font-size: 15px; cursor: pointer; text-align: center; border-radius: 10px; -webkit-tap-highlight-color: transparent; }
.cp-delete-btn:active { background: rgba(255,0,0,.06); }
.cur-symbol { font-size: 18px; font-weight: 600; min-width: 28px; }
.cur-code-badge { font-size: 12px; color: var(--hint); font-weight: 400; }
.er-arrow { font-size: 16px; color: var(--hint); flex-shrink: 0; width: 20px; text-align: center; }
.er-to-code { font-size: 15px; font-weight: 600; }
.er-rate { font-size: 15px; font-variant-numeric: tabular-nums; margin-right: 6px; }
.er-meta { font-size: 12px; color: var(--hint); white-space: nowrap; }
.er-pair-row { display: flex; align-items: flex-end; gap: 8px; }
.er-pair-arrow { font-size: 20px; color: var(--hint); padding-bottom: 10px; flex-shrink: 0; }
.er-src-badge { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .02em; padding: 1px 5px; border-radius: 4px; background: var(--secondary-bg); color: var(--hint); white-space: nowrap; }
.er-src-badge.auto { color: #2196F3; background: rgba(33,150,243,.12); }
.er-src-badge.cbr  { color: #4CAF50; background: rgba(76,175,80,.12); }
.er-last-update { font-size: 12px; color: var(--hint); padding: 4px 16px 8px; }
.er-delete-btn { background: none; border: none; padding: 4px 6px; cursor: pointer; font-size: 16px; color: var(--hint); line-height: 1; }
.er-delete-btn:hover { color: #e53935; }
.cur-not-listed { font-size: 11px; color: #FF9800; background: rgba(255,152,0,.12); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }

/* ── Upcoming row ──────────────────────────────────────────────── */
.upcoming-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.upcoming-row + .upcoming-row { border-top: 1px solid rgba(0,0,0,0.06); }
.upcoming-date-badge {
  text-align: center;
  width: 36px;
  flex-shrink: 0;
}
.upcoming-day   { font-size: 16px; font-weight: 700; line-height: 1; }
.upcoming-month { font-size: 10px; color: var(--hint); }
.upcoming-info  { flex: 1; }
.upcoming-title { font-size: 14px; font-weight: 500; }
.upcoming-sub   { font-size: 12px; color: var(--hint); margin-top: 2px; }
.upcoming-amount { font-size: 14px; font-weight: 600; }
.upcoming-amount.expense { color: var(--expense); }
.upcoming-amount.income  { color: var(--income); }

/* ── Confirm action button ─────────────────────────────────────── */
.action-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 8px 12px;
  padding: 14px;
  background: var(--secondary-bg);
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.action-btn.primary { background: var(--button); color: var(--button-text); }
.action-btn.danger  { color: var(--expense); background: none; }
.action-btn:active  { opacity: .7; }

/* ── Pill button (edit action in header) ────────────────────────────── */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--button);
  color: var(--button);
  background: none;
  font-size: 13px;
  font-weight: 500;
  min-height: 34px;
  min-width: 44px;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill-btn:active { background: rgba(36,129,204,.1); }

/* ── Detail v2 ─────────────────────────────────────────────────────── */
.detail-description {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin-top: 8px;
  line-height: 1.3;
}

.detail-rows-v {
  background: var(--bg);
  border-radius: 14px;
  margin: 0 12px 8px;
  overflow: hidden;
}

.detail-row-v {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  min-height: 52px;
}
.detail-row-v + .detail-row-v { border-top: 1px solid rgba(0,0,0,0.06); }

.detail-row-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.detail-row-body   { flex: 1; min-width: 0; }
.detail-row-label  { font-size: 11px; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 2px; }
.detail-row-value  { font-size: 14px; line-height: 1.3; }

.detail-actions { padding: 4px 0 8px; }


/* ── Edit menu (step-by-step) ───────────────────────────────────────── */
.edit-menu {
  background: var(--bg);
  border-radius: 14px;
  margin: 8px 12px;
  overflow: hidden;
}

.edit-menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  width: 100%;
  text-align: left;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  border-top: 1px solid rgba(0,0,0,0.06);
  transition: background .1s;
}
.edit-menu-row:first-child { border-top: none; }
.edit-menu-row:active { background: rgba(0,0,0,0.04); }
.edit-menu-row.active { background: rgba(36,129,204,.06); }

.edit-row-icon  { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.edit-row-body  { flex: 1; min-width: 0; }
.edit-row-label { font-size: 11px; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 2px; }
.edit-row-value { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-row-chevron { color: var(--hint); font-size: 20px; flex-shrink: 0; }

/* ── Field editor ───────────────────────────────────────────────────── */
.field-editor { padding: 16px 12px; }

.field-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: 14px;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  resize: none;
}
.field-input:focus { border-color: var(--button); }
.field-input-ta { line-height: 1.5; }

/* ── Edit form (two-level) ──────────────────────────────────────────── */
.ed-section { margin: 8px 12px; }

.ed-group {
  background: var(--bg);
  border-radius: 14px;
  overflow: hidden;
}

.ed-item { padding: 0 16px; }
.ed-item + .ed-item { border-top: 1px solid rgba(0,0,0,0.06); }

.ed-label {
  display: block;
  font-size: 11px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  padding-top: 10px;
  margin-bottom: 0;
}

.ed-input {
  display: block;
  width: 100%;
  padding: 8px 0 10px;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
input.ed-input[type="number"] { -moz-appearance: textfield; }
input.ed-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.ed-select {
  display: block;
  width: 100%;
  padding: 8px 0 10px;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  padding-right: 20px;
  cursor: pointer;
}

.ed-textarea { min-height: 60px; resize: none; line-height: 1.5; }

.ed-readonly {
  padding: 8px 0 10px;
  font-size: 15px;
  color: var(--hint);
}

/* Amount row */
.ed-row-pair { display: flex; align-items: flex-end; gap: 0; }
.ed-row-pair .ed-input { flex: 1; }

/* Read-only currency badge next to amount */
.ed-currency-badge {
  flex: 0 0 auto;
  padding: 8px 0 10px 12px;
  border-left: 1px solid rgba(0,0,0,0.08);
  font-size: 15px;
  font-weight: 600;
  color: var(--hint);
  white-space: nowrap;
  line-height: 1.6;
}

/* Hint below account select */
.ed-currency-hint {
  font-size: 12px;
  color: var(--hint);
  padding-bottom: 10px;
  line-height: 1.4;
}
.ed-currency-hint strong { color: var(--text); font-weight: 600; }

/* Advanced section toggle */
.ed-advanced { margin: 0 12px 8px; }

.ed-advanced-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 12px 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--button);
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}
.ed-advanced-toggle:active { opacity: .7; }

/* ── Inline editing (transaction-detail v1.7) ───────────────────────────────── */

/* Row container: overrides .detail-row-v padding/flex so children control layout */
.row-container {
  padding: 0;
  display: block;
  min-height: 0;
}

/* View state — full tap area, clear pointer affordance */
.row-view {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  min-height: 52px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
  user-select: none;
  -webkit-user-select: none;
}
.row-view:active { background: rgba(0,0,0,0.06); }

/* Editing state — blue tinted, clear visual distinction */
.row-edit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  min-height: 56px;
  background: rgba(36,129,204,.07);
  border-left: 3px solid var(--button);
}
.row-edit-tall { align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }

.row-edit-body { flex: 1; min-width: 0; }

/* Chevron: slightly larger, clear hint colour */
.row-chevron {
  color: var(--hint);
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
  margin-left: auto;
}

.row-cancel-btn {
  flex-shrink: 0;
  padding: 6px 10px;
  min-width: 36px;
  min-height: 36px;
  color: var(--hint);
  font-size: 16px;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/*
 * inline-select: DO NOT use -webkit-appearance:none here.
 * On iOS Safari / WKWebView, removing the native appearance prevents the
 * native picker wheel from opening when the element is focused programmatically.
 * Keep the native look; we style the surrounding container instead.
 */
.inline-select {
  display: block;
  width: 100%;
  padding: 10px 8px 10px 0;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  /* Native appearance kept intentionally — required for iOS picker */
  margin-top: 2px;
  min-height: 44px;
}

/* Amount block inline editor */
.amt-view {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.amt-view:active { opacity: .8; }

.amt-editor { padding: 8px 20px 4px; }

.inline-field-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.inline-inp-lg {
  flex: 1;
  font-size: 28px;
  font-weight: 700;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  -webkit-appearance: none;
  -moz-appearance: textfield;
  padding: 0;
  min-width: 0;
}
.inline-inp-lg::-webkit-inner-spin-button { -webkit-appearance: none; }

.inline-inp {
  flex: 1;
  font-size: 15px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  outline: none;
  color: var(--text);
  padding: 4px 0;
  -webkit-appearance: none;
}

.inline-ta {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 14px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  outline: none;
  color: var(--text);
  padding: 4px 0;
  resize: none;
  margin-top: 4px;
}

.inline-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.inline-ok {
  flex: 1;
  padding: 8px 16px;
  background: var(--button);
  color: var(--button-text);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.inline-ok:active { opacity: .8; }

.inline-cancel-sm {
  padding: 8px 12px;
  min-height: 36px;
  color: var(--hint);
  font-size: 14px;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cp-action-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cp-action-btn:active { opacity: .7; }

.detail-desc-hint {
  font-size: 13px;
  color: var(--hint);
  margin-top: 4px;
}

/* ── tx-meta-line: status + date chip under amount block ────────────────── */
.tx-meta-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--hint);
}
.tx-status-icon { font-size: 14px; line-height: 1; }
.tx-status-text { font-weight: 500; color: var(--text); }
.tx-meta-dot    { color: var(--hint); }
.tx-meta-date   { color: var(--hint); }

.tx-dates-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
}
.tx-date-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--hint);
}
.tx-date-lbl { opacity: .7; }
.tx-date-rec { opacity: .7; }

.tx-confirm-sm {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--button);
  color: var(--button);
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  min-height: 30px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  margin-left: 4px;
}
.tx-confirm-sm:active { background: rgba(36,129,204,.1); }

/* Read-only text row value: wrap + muted */
.detail-ro-text {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Source text card (standalone block between fields and Дополнительно) ── */
.tx-src-card {
  background: var(--bg);
  border-radius: 14px;
  margin: 0 12px 8px;
  padding: 12px 16px;
}
.tx-src-label {
  font-size: 11px;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  margin-bottom: 6px;
}
.tx-src-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: .7;
}
.tx-src-toggle {
  margin-top: 6px;
  padding: 0;
  background: none;
  border: none;
  color: var(--button);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: block;
}

/* Empty-value action hint: "Выбрать проект", "Добавить" etc. */
.row-hint-action {
  color: var(--button);
  font-size: 14px;
}

/* Nav row (Дополнительно ›) — cursor pointer, no edit affordance */
.row-view-nav { cursor: pointer; }

/* Detail source hint — bottom of card, no border */
.detail-source-hint {
  font-size: 11px;
  color: var(--hint);
  text-align: center;
  padding: 8px 16px 12px;
}

/* ── Account detail ─────────────────────────────────────────────── */
.acc-detail-header {
  background: var(--bg);
  border-radius: 14px;
  margin: 0 12px 8px;
  padding: 20px 16px 16px;
  text-align: center;
}
.acc-detail-icon     { font-size: 40px; margin-bottom: 8px; line-height: 1; }
.acc-detail-name     { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.acc-detail-meta     { font-size: 13px; color: var(--hint); }
.acc-detail-balance  { font-size: 24px; font-weight: 700; margin-top: 8px; }
.acc-detail-illiquid { font-size: 11px; color: var(--hint); margin-top: 4px; }
.acc-liq-chip        { flex-shrink: 0; font-size: 16px; width: 28px; text-align: center; }
.acc-liq-chip.on     { color: var(--income); }
.acc-liq-chip.off    { color: var(--hint); }

/* ── Reconciliation ─────────────────────────────────────────────── */
.acc-recon-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.acc-recon-cta {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.acc-recon-new-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--button);
  -webkit-tap-highlight-color: transparent;
}
.acc-recon-empty {
  font-size: 13px;
  color: var(--hint);
  padding: 8px 16px 12px;
  text-align: center;
}
.recon-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.recon-diff {
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}
.recon-diff-pos  { color: var(--income); }
.recon-diff-neg  { color: var(--expense); }
.recon-diff-zero { color: var(--hint); font-size: 13px; }
.recon-del-btn {
  flex-shrink: 0;
  font-size: 14px;
  color: var(--hint);
  padding: 2px 6px;
  -webkit-tap-highlight-color: transparent;
}
.acc-default-badge {
  color: var(--income, #34c759);
  font-weight: 600;
}
.acc-default-remove-btn {
  flex-shrink: 0;
  font-size: 14px;
  color: var(--hint);
  padding: 2px 8px;
  -webkit-tap-highlight-color: transparent;
}
.recon-expected-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--secondary-bg);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.recon-expected-label { font-size: 13px; color: var(--hint); }
.recon-expected-val   { font-size: 15px; font-weight: 600; }
.recon-diff-live {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 500;
  min-height: 20px;
  text-align: center;
}
