/* ==========================================================================
   Тандем — дизайн-система: жёсткий стекломорфизм
   ========================================================================== */
:root {
  --bg: #0b0f1a;
  --bg-2: #0e1424;
  --text: #f4f6ff;
  --text-dim: rgba(224, 230, 255, 0.62);
  --text-faint: rgba(224, 230, 255, 0.38);

  --glass: rgba(255, 255, 255, 0.065);
  --glass-strong: rgba(255, 255, 255, 0.10);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-border-bright: rgba(255, 255, 255, 0.28);

  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --pink: #ff5eb4;
  --green: #34e39b;
  --red: #ff6b7a;
  --amber: #ffc555;

  --grad-accent: linear-gradient(135deg, #7c5cff 0%, #00d4ff 100%);
  --grad-pink: linear-gradient(135deg, #ff5eb4 0%, #7c5cff 100%);
  --grad-green: linear-gradient(135deg, #34e39b 0%, #00d4ff 100%);

  --r-lg: 26px;
  --r-md: 20px;
  --r-sm: 14px;
  --shadow: 0 18px 44px rgba(3, 6, 18, 0.55);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* --- Фоновые блобы ------------------------------------------------------ */
.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(120% 90% at 50% 0%, #131a30 0%, var(--bg) 60%); }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; animation: drift 24s ease-in-out infinite alternate; }
.blob-1 { width: 46vmax; height: 46vmax; top: -18vmax; left: -12vmax; background: #5b3df0; }
.blob-2 { width: 40vmax; height: 40vmax; bottom: -16vmax; right: -14vmax; background: #0891b2; animation-delay: -8s; }
.blob-3 { width: 26vmax; height: 26vmax; top: 34%; right: -10vmax; background: #be2f8c; opacity: 0.34; animation-delay: -16s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(5vmax, 4vmax) scale(1.12); }
}

/* --- Стекло -------------------------------------------------------------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--glass-border);
}

.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
}
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255,255,255,0.10) 0%, transparent 38%);
  pointer-events: none;
}
.card.clickable { cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease; }
.card.clickable:active { transform: scale(0.985); border-color: var(--glass-border-bright); }

/* --- Разметка ------------------------------------------------------------ */
.view {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 16px calc(112px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: view-in 0.24s ease;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.page-sub { color: var(--text-dim); font-size: 14px; margin-top: 2px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.h-scroll { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll > * { scroll-snap-align: start; flex-shrink: 0; }

.section-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 0; }
.section-title .link { font-size: 13px; font-weight: 600; color: var(--accent-2); cursor: pointer; text-decoration: none; }

/* --- Типографика денег ---------------------------------------------------- */
.money-xl { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.money-lg { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.money-md { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }

/* --- Таббар ---------------------------------------------------------------- */
.tabbar[hidden] { display: none; }
.tabbar {
  position: fixed;
  left: 50%; bottom: calc(12px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(94%, 480px);
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-radius: 30px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint); text-decoration: none;
  font-size: 10px; font-weight: 600;
  padding: 6px 12px; border-radius: 16px;
  transition: color 0.15s ease;
  min-width: 58px;
}
.tab-icon { font-size: 19px; line-height: 1; }
.tab.active { color: var(--text); }
.tab.active .tab-icon { background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.fab {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 1px solid var(--glass-border-bright);
  background: var(--grad-accent);
  color: #fff;
  font-size: 30px; font-weight: 400; line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(94, 70, 220, 0.55);
  transition: transform 0.15s ease;
  margin-top: -26px;
}
.fab:active { transform: scale(0.92); }

/* --- Кнопки ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text);
  font: inherit; font-size: 15px; font-weight: 700;
  border-radius: var(--r-sm);
  padding: 13px 18px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 0.12s ease, opacity 0.12s ease;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--grad-accent); border-color: transparent; box-shadow: 0 8px 24px rgba(94, 70, 220, 0.4); }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 122, 0.35); background: rgba(255, 107, 122, 0.08); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 14px; font-size: 13px; border-radius: 12px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.external-link { min-width: 0; overflow: hidden; }
.link-ellipsis { display: block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 13px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text); font-size: 17px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  position: relative;
}
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 8px var(--pink);
}

/* --- Формы ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.input, select.input, textarea.input {
  width: 100%;
  font: inherit; font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 13px 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22); }
.input::placeholder { color: var(--text-faint); }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
select.input option { background: var(--bg-2); color: var(--text); }
textarea.input { resize: vertical; min-height: 68px; }

.amount-input {
  font-size: 40px; font-weight: 800; letter-spacing: -0.02em;
  text-align: center;
  background: transparent; border: none;
  color: var(--text); width: 100%;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.amount-input::placeholder { color: var(--text-faint); }

/* Чипы */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.emoji-picker { display: grid; gap: 8px; }
.emoji-custom { height: 40px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
  font-family: inherit;
}
.chip.active { color: #fff; background: var(--grad-accent); border-color: transparent; box-shadow: 0 4px 16px rgba(94, 70, 220, 0.4); }
.chip.sm { padding: 6px 11px; font-size: 13px; }

/* Сегментированный переключатель */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 4px; gap: 4px;
}
.seg button {
  font: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--text-dim);
  background: transparent; border: none;
  border-radius: 11px;
  padding: 10px 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg button.active { color: #fff; background: var(--grad-accent); box-shadow: 0 4px 14px rgba(94, 70, 220, 0.35); }
.seg button.active.exp { background: linear-gradient(135deg, #ff6b7a, #ff5eb4); box-shadow: 0 4px 14px rgba(255, 94, 140, 0.3); }
.seg button.active.inc { background: var(--grad-green); box-shadow: 0 4px 14px rgba(52, 227, 155, 0.3); }

/* Переключатель (switch) */
.switch { position: relative; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease;
}
.switch .track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}
.switch input:checked + .track { background: var(--grad-accent); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(20px); }

/* --- Модалки / шторки ------------------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 6, 14, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.sheet {
  width: min(100%, 560px);
  max-height: calc(100dvh - 40px - var(--safe-top));
  overflow-y: auto;
  background: rgba(20, 25, 45, 0.86);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  backdrop-filter: blur(30px) saturate(1.6);
  border: 1px solid var(--glass-border-bright);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  animation: sheet-up 0.26s cubic-bezier(0.32, 0.9, 0.35, 1);
  display: flex; flex-direction: column; gap: 14px;
}
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0.5; } }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.25); margin: 4px auto 2px; flex-shrink: 0; }
.sheet-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }

/* --- Тосты ------------------------------------------------------------------ */
#toast-root { position: fixed; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(92%, 420px); }
.toast {
  background: rgba(24, 30, 52, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border-bright);
  border-radius: 16px;
  padding: 13px 16px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.error { border-color: rgba(255, 107, 122, 0.5); }
.toast.success { border-color: rgba(52, 227, 155, 0.5); }
@keyframes toast-in { from { transform: translateY(-14px); opacity: 0; } }

/* --- Списки операций --------------------------------------------------------- */
.op-day { font-size: 12.5px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; padding: 10px 4px 2px; }
.op-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
.op-item:last-child { border-bottom: none; }
.op-emoji {
  width: 42px; height: 42px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
}
.op-title { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-sub { font-size: 12.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* Аватары */
.avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  border: 2px solid var(--glass-border-bright);
  background: var(--glass-strong);
}
.avatar.lg { width: 72px; height: 72px; font-size: 34px; }

/* --- Прогресс ----------------------------------------------------------------- */
.progress { height: 9px; border-radius: 6px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.progress > div { height: 100%; border-radius: 6px; background: var(--grad-accent); transition: width 0.4s ease; min-width: 0; }
.progress.green > div { background: var(--grad-green); }
.progress.pink > div { background: var(--grad-pink); }
.progress.over > div { background: linear-gradient(135deg, #ff6b7a, #ffc555); }

/* Чек-лист */
.task {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.task:last-child { border-bottom: none; }
.task-check {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 9px;
  border: 2px solid var(--glass-border-bright);
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 14px; font-weight: 800;
  transition: all 0.15s ease;
}
.task.done .task-check { background: var(--grad-green); border-color: transparent; color: #06281a; }
.task-title { font-size: 15px; font-weight: 600; }
.task.done .task-title { color: var(--text-faint); text-decoration: line-through; }

/* --- Спец-карточки -------------------------------------------------------------- */
.hero-card {
  border-radius: var(--r-lg);
  padding: 22px 20px;
  background: linear-gradient(150deg, rgba(124, 92, 255, 0.32), rgba(0, 212, 255, 0.13) 55%, rgba(255, 94, 180, 0.14)), var(--glass);
  border: 1px solid var(--glass-border-bright);
}
.stat-pill {
  border-radius: var(--r-sm);
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  flex: 1; min-width: 0;
}
.env-card { width: 158px; padding: 14px; border-radius: var(--r-md); }
.env-icon { font-size: 26px; }

.lock-badge { font-size: 11px; opacity: 0.8; }

.empty {
  text-align: center; padding: 34px 16px; color: var(--text-faint);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.empty .big { font-size: 40px; opacity: 0.9; }

/* --- Экран входа ------------------------------------------------------------------ */
.auth-wrap { min-height: calc(100dvh - 120px); display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.logo-mark {
  width: 84px; height: 84px; border-radius: 26px;
  margin: 0 auto;
  background: url('/icons/icon-192.png') center/cover;
  border: 1px solid var(--glass-border-bright);
  box-shadow: 0 16px 40px rgba(94, 70, 220, 0.5);
}
.app-name { text-align: center; font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.app-name .grad { background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* --- Графики ------------------------------------------------------------------------ */
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 4px; flex-shrink: 0; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 8px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar { width: 45%; max-width: 16px; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bar.inc { background: var(--grad-green); }
.bar.exp { background: var(--grad-pink); }
.bar-label { font-size: 10.5px; color: var(--text-faint); font-weight: 600; }

/* --- Календарь --------------------------------------------------------------------------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { margin-bottom: 6px; text-align: center; font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.cal-cell {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: all 0.12s ease;
  padding: 0;
}
.cal-cell:active { transform: scale(0.94); }
.cal-cell.today { border-color: var(--glass-border-bright); }
.cal-cell.sel { background: var(--grad-accent); box-shadow: 0 4px 14px rgba(94, 70, 220, 0.4); }
.cal-dots { display: flex; gap: 3px; height: 5px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cal-dot.ops { background: rgba(255, 255, 255, 0.55); }
.cal-dot.plan { background: var(--amber); }
.cal-dot.rec { background: var(--accent-2); }
.cal-cell.sel .cal-dot { background: #fff; }
.legend-item.tiny { display: inline-flex; align-items: center; gap: 5px; color: var(--text-faint); }

/* --- Уведомления ----------------------------------------------------------------------- */
.ntf-item { display: flex; gap: 12px; padding: 12px 2px; border-bottom: 1px solid rgba(255,255,255,0.06); align-items: flex-start; }
.ntf-item:last-child { border-bottom: none; }
.ntf-item.unread .ntf-text { font-weight: 700; }
.ntf-icon { font-size: 18px; margin-top: 1px; }
.ntf-text { font-size: 14px; line-height: 1.4; }

/* --- Десктоп ------------------------------------------------------------------------------ */
@media (min-width: 900px) {
  .view { max-width: 760px; padding-top: 34px; }
  .grid-2.desktop-3 { grid-template-columns: repeat(3, 1fr); }
  .tabbar { bottom: 24px; }
  .env-card { width: 178px; }
  body { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
