/* ============================================================
   Financer — современный слой интерфейса и мобильное приложение
   Подключается после style.css, поэтому может переопределять базовые стили.
   ============================================================ */

:root {
  --brand: #4f46e5;
  --brand-2: #0ea5e9;
  --brand-3: #22c55e;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --line: #e6ebf3;
  --card: #ffffff;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 28px 70px rgba(15, 23, 42, 0.16);
  --grad: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
  --grad-green: linear-gradient(135deg, #16a34a 0%, #22d3ee 100%);
}

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1100px 560px at 8% -12%, #dbeafe 0%, transparent 55%),
    radial-gradient(900px 480px at 102% 0%, #ede9fe 0%, transparent 50%),
    #f4f7fb;
  -webkit-font-smoothing: antialiased;
}

.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex: 0 0 auto;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}
.brand.small .brand-logo { width: 27px; height: 27px; border-radius: 8px; }

.auth-app-link {
  display: flex; align-items: center; gap: 11px; margin-top: 18px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 16px; background: #f8fafc;
  color: var(--ink); text-decoration: none; transition: background 0.15s, transform 0.15s;
}
.auth-app-link:hover { background: #eef2ff; text-decoration: none; transform: translateY(-1px); }
.auth-app-link > span:first-child {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: #e0e7ff; font-size: 1rem; flex: 0 0 auto;
}
.auth-app-link strong { display: block; font-size: 0.8rem; }
.auth-app-link small { display: block; color: var(--muted); font-size: 0.68rem; margin-top: 1px; }
.auth-app-arrow { margin-left: auto; color: var(--brand); font-weight: 800; font-size: 1.1rem; }

.badge-plan {
  display: inline-block; margin-left: 5px; padding: 2px 7px; border-radius: 999px;
  background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa;
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  vertical-align: 1px;
}

/* ── Экран загрузки и аварийное сообщение ───────────────────── */

.boot-loading {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px;
  background:
    radial-gradient(700px 420px at 20% 0%, #dbeafe 0%, transparent 60%),
    radial-gradient(600px 380px at 100% 100%, #ede9fe 0%, transparent 55%),
    #f4f7fb;
  color: #475569;
}
.boot-loading.hidden { display: none !important; }
.boot-loading p { font-size: 0.82rem; font-weight: 700; }
.boot-icon {
  width: 68px; height: 68px; border-radius: 20px; object-fit: cover;
  box-shadow: 0 16px 34px rgba(79, 70, 229, 0.28);
}
.boot-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #e2e8f0; border-top-color: var(--brand);
  animation: ftSpin 0.8s linear infinite;
}
@keyframes ftSpin { to { transform: rotate(360deg); } }

.boot-error {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.boot-error.hidden { display: none !important; }
.boot-card {
  width: 100%; max-width: 360px; padding: 28px 22px; text-align: center;
  background: #fff; border-radius: 24px; box-shadow: 0 30px 70px rgba(15, 23, 42, 0.35);
}
.boot-card .boot-icon { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 12px; }
.boot-card h2 { font-size: 1.2rem; margin-bottom: 8px; }
.boot-card p { color: var(--muted); font-size: 0.84rem; line-height: 1.5; margin-bottom: 18px; }

.page { animation: ftFadeUp 0.35s ease both; }
@keyframes ftFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── Типографика и общие элементы ───────────────────────────── */

.page-head { align-items: flex-start; }
.page-head h1 { letter-spacing: -0.02em; }
.page-sub { margin-top: 3px; color: var(--muted); font-size: 0.84rem; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(79, 70, 229, 0.1); color: var(--brand);
  font-size: 0.75rem; font-weight: 700; white-space: nowrap;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; font-weight: 600; transition: transform 0.12s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--grad); border: none; color: #fff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.28);
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 12px 26px rgba(79, 70, 229, 0.34); }
.btn.ghost { border: 1px solid transparent; }
.btn.block { width: 100%; }
.btn-lg { padding: 13px 22px; border-radius: 14px; font-size: 0.95rem; }
.btn-ico, .nav-ico {
  width: 19px; height: 19px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

input, select, textarea { border-radius: 12px; }
label { font-weight: 600; }
label input, label select, label textarea { background: #f8fafc; }
label input:focus, label select:focus, label textarea:focus { background: #fff; }

.card {
  border-radius: 20px; border: 1px solid rgba(15, 23, 42, 0.05);
  box-shadow: var(--shadow-soft);
}
.card h2 { letter-spacing: -0.01em; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-sub { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.card-chip {
  display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px;
  background: #f1f5f9; color: #475569; font-size: 0.72rem; font-weight: 700; white-space: nowrap;
}

.chart-box { position: relative; height: 310px; max-height: none; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

/* ── Навигация ─────────────────────────────────────────────── */

.sidebar {
  background: linear-gradient(170deg, #0b1220 0%, #111c33 55%, #0d1b2f 100%);
}
.sidebar .brand { letter-spacing: -0.02em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border-radius: 12px; margin: 2px 8px; padding: 10px 12px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); transform: translateX(2px); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.95), rgba(14, 165, 233, 0.9));
  color: #fff; box-shadow: 0 10px 24px rgba(30, 64, 175, 0.35);
}
.nav-ico { width: 18px; height: 18px; }

/* ── KPI ───────────────────────────────────────────────────── */

.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.kpi-card {
  border: 1px solid rgba(15, 23, 42, 0.05); border-left: 0;
  border-radius: 20px; padding: 18px; overflow: hidden; position: relative;
  box-shadow: var(--shadow-soft);
}
.kpi-card h3 { font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; font-size: 0.66rem; }
.kpi-card .val { font-size: 1.35rem; letter-spacing: -0.02em; }
.kpi-card .kpi-ico {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: #eef2ff; color: var(--brand); font-size: 1rem; margin-bottom: 10px;
}
.kpi-card.hero {
  grid-column: 1 / -1; color: #fff; border: none; min-height: 164px;
  background:
    radial-gradient(500px 240px at 100% 0%, rgba(14, 165, 233, 0.55) 0%, transparent 60%),
    linear-gradient(135deg, #111827 0%, #1e293b 48%, #0f766e 100%);
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.26);
}
.kpi-card.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -70px;
  width: 230px; height: 230px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hero-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: #c7d2fe; font-weight: 700; }
.hero-period {
  padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12);
  color: #e0e7ff; font-size: 0.68rem; font-weight: 600; white-space: nowrap;
}
.hero-value { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.04em; margin: 14px 0 12px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; }
.hero-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: #f8fafc; font-size: 0.74rem; font-weight: 600;
}
.hero-chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ── Инфографика: инсайты и доли ────────────────────────────── */

.insights { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.insight-card {
  background: var(--card); border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 18px; padding: 15px; box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column; gap: 4px;
}
.insight-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.insight-top .i-ico {
  width: 27px; height: 27px; border-radius: 9px; display: grid; place-items: center;
  background: #f1f5f9; font-size: 0.82rem;
}
.insight-value { font-size: 1.08rem; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.insight-hint { color: var(--muted); font-size: 0.72rem; }

.share-list { display: flex; flex-direction: column; gap: 11px; margin-top: 4px; }
.share-row { display: flex; flex-direction: column; gap: 5px; }
.share-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.8rem; }
.share-name { display: flex; align-items: center; gap: 7px; min-width: 0; }
.share-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.share-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.share-amount { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.share-pct { font-weight: 800; font-size: 0.75rem; color: var(--ink); min-width: 38px; text-align: right; }
.share-track { height: 8px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.share-fill { height: 100%; border-radius: 999px; transition: width 0.65s cubic-bezier(0.22, 1, 0.36, 1); }
.share-empty { color: var(--muted); font-size: 0.82rem; padding: 10px 0; }

/* ── Баннер приложения ─────────────────────────────────────── */

.app-banner {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 14px 46px 14px 16px; margin-bottom: 18px; border-radius: 18px;
  background:
    radial-gradient(360px 160px at 90% 0%, rgba(56, 189, 248, 0.55), transparent 65%),
    linear-gradient(120deg, #0f172a, #1e3a8a);
  color: #fff; box-shadow: 0 16px 36px rgba(30, 58, 138, 0.28); overflow: hidden;
}
.app-banner-ico {
  width: 40px; height: 40px; border-radius: 13px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.15rem;
  background: rgba(255, 255, 255, 0.14);
}
.app-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-banner-text strong { font-size: 0.9rem; }
.app-banner-text span { color: #c7d2fe; font-size: 0.76rem; }
.app-banner .btn.primary { margin-left: auto; background: #fff; color: #0f172a; box-shadow: none; }
.app-banner-close {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.14); color: #fff;
  font-size: 1rem; line-height: 1; cursor: pointer;
}

/* ── Страница приложения ───────────────────────────────────── */

.app-hero {
  position: relative; display: grid; grid-template-columns: 1.15fr 0.85fr;
  gap: 28px; align-items: center; padding: 34px; margin-bottom: 20px;
  border-radius: 28px; overflow: hidden; color: #fff;
  background:
    radial-gradient(520px 260px at 95% 0%, rgba(14, 165, 233, 0.5), transparent 60%),
    radial-gradient(420px 240px at 0% 100%, rgba(34, 197, 94, 0.22), transparent 60%),
    linear-gradient(140deg, #0b1220, #111c33 52%, #0c4a6e);
  box-shadow: var(--shadow-lg);
}
.app-hero::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
  background-size: 22px 22px; opacity: 0.35; pointer-events: none;
}
.app-hero-copy { position: relative; z-index: 1; }
.eyebrow {
  display: inline-flex; padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: #bae6fd;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
}
.app-hero h2 { font-size: 2rem; line-height: 1.12; letter-spacing: -0.035em; margin: 14px 0 12px; }
.app-hero p { color: #cbd5e1; font-size: 0.88rem; max-width: 460px; }
.app-hero .row { margin-top: 20px; }
.app-hero .btn.ghost { color: #e2e8f0; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.06); }
.app-meta { margin-top: 14px; color: #94a3b8; font-size: 0.74rem; }

.phone-mock {
  position: relative; z-index: 1; width: 268px; max-width: 100%; margin: 0 auto;
  padding: 12px 10px 16px; border: 9px solid #050914; border-radius: 42px;
  background: #0b1220; box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  transform: rotate(-2deg);
}
.phone-speaker { width: 54px; height: 5px; border-radius: 999px; background: #1e293b; margin: 0 auto 8px; }
.phone-screen {
  background: linear-gradient(170deg, #ffffff, #eef4ff);
  border-radius: 29px; padding: 14px; color: #0f172a; min-height: 352px;
}
.mini-top { display: flex; justify-content: space-between; align-items: center; font-size: 0.68rem; color: #64748b; font-weight: 700; }
.mini-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-3); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15); }
.mini-balance {
  margin-top: 10px; padding: 13px; border-radius: 16px; color: #fff;
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
}
.mini-balance small { display: block; font-size: 0.6rem; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.08em; }
.mini-balance strong { display: block; font-size: 1.25rem; letter-spacing: -0.03em; margin-top: 3px; }
.mini-balance em { font-style: normal; font-size: 0.58rem; font-weight: 700; background: rgba(255, 255, 255, 0.2); padding: 2px 7px; border-radius: 999px; }
.mini-bars { display: flex; align-items: flex-end; gap: 6px; height: 68px; margin: 14px 2px 8px; }
.mini-bars i { flex: 1; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, #818cf8, #22d3ee); }
.mini-donut-wrap { display: flex; align-items: center; gap: 13px; margin: 10px 0; }
.mini-donut {
  width: 74px; height: 74px; border-radius: 50%; flex: 0 0 auto; position: relative;
  background: conic-gradient(#4f46e5 0 42%, #f59e0b 42% 70%, #22c55e 70% 86%, #e2e8f0 86% 100%);
}
.mini-donut::after { content: ""; position: absolute; inset: 17px; border-radius: 50%; background: #fff; }
.mini-legend { display: flex; flex-direction: column; gap: 5px; font-size: 0.62rem; color: #475569; }
.mini-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.mini-list div { display: flex; justify-content: space-between; font-size: 0.66rem; padding: 6px 0; border-top: 1px solid #e2e8f0; }
.mini-list b { color: #0f172a; }

.feature-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.feature-card {
  background: var(--card); border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 18px; padding: 16px; box-shadow: var(--shadow-soft);
}
.feature-ico {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: #eef2ff; font-size: 1.05rem; margin-bottom: 10px;
}
.feature-card h3 { font-size: 0.88rem; margin-bottom: 4px; }
.feature-card p { color: var(--muted); font-size: 0.76rem; }

.steps { margin: 8px 0 0 18px; color: var(--muted); font-size: 0.85rem; }
.steps li { margin: 6px 0; padding-left: 2px; }
.native-box {
  margin-top: 12px; padding: 12px 14px; border-radius: 14px;
  background: #f0f9ff; border: 1px solid #bae6fd; color: #075985; font-size: 0.78rem;
}
.app-note { color: #334155; font-size: 0.84rem; }
.app-note strong { color: var(--ink); }

/* ── Мобильная навигация / шторка / FAB ────────────────────── */

.mobile-nav,
.fab,
.mobile-sheet { display: none; }

/* ── Таблицы ───────────────────────────────────────────────── */

.table th { letter-spacing: 0.04em; }
.table tbody tr { transition: background 0.15s; }

/* ── Адаптив ───────────────────────────────────────────────── */

@media (max-width: 900px) {
  .sidebar { display: none; }
  .app { display: block; min-height: 100dvh; }
  .content { padding: 16px 14px calc(104px + env(safe-area-inset-bottom)); }

  .mobile-nav {
    display: flex; position: fixed; left: 10px; right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 800;
    padding: 6px; gap: 2px; border-radius: 22px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.07);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  }
  .mnav-item {
    flex: 1 1 0; min-width: 0; border: 0; background: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 8px 2px; border-radius: 16px; color: #64748b;
    font-family: inherit; font-size: 0.58rem; font-weight: 700;
    transition: color 0.15s, background 0.15s, transform 0.15s;
  }
  .mnav-item .nav-ico { width: 21px; height: 21px; }
  .mnav-item.active { color: #fff; background: var(--grad); box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3); }
  .mnav-item:active { transform: scale(0.97); }

  .fab {
    display: none; align-items: center; justify-content: center;
    position: fixed; right: 18px; bottom: calc(86px + env(safe-area-inset-bottom));
    z-index: 810; width: 56px; height: 56px; border: 0; border-radius: 50%;
    background: var(--grad-green); color: #fff; font-size: 1.6rem; font-weight: 300; line-height: 1;
    box-shadow: 0 16px 32px rgba(22, 163, 74, 0.36); cursor: pointer;
  }
  body[data-route="dashboard"] .fab,
  body[data-route="transactions"] .fab { display: flex; }

  #page-recurring .page-head .row { width: 100%; display: grid; grid-template-columns: 1fr; gap: 8px; }
  #page-recurring .page-head .row .btn { width: 100%; }

  .mobile-sheet { display: block; position: fixed; inset: 0; z-index: 900; }
  .sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
  .sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 8px 16px calc(22px + env(safe-area-inset-bottom));
    background: #fff; border-radius: 26px 26px 0 0;
    box-shadow: 0 -20px 50px rgba(15, 23, 42, 0.2);
    animation: ftSheetUp 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  }
  @keyframes ftSheetUp { from { transform: translateY(100%); } to { transform: none; } }
  .sheet-grab { width: 42px; height: 4px; border-radius: 999px; background: #cbd5e1; margin: 6px auto 12px; }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .sheet-head strong { font-size: 1.05rem; }
  .sheet-close { border: 0; background: #f1f5f9; width: 32px; height: 32px; border-radius: 50%; font-size: 1.15rem; color: #475569; cursor: pointer; }
  .sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .sheet-item {
    display: flex; align-items: center; gap: 10px; padding: 14px;
    border: 1px solid var(--line); border-radius: 16px; background: #fff;
    font-family: inherit; font-size: 0.82rem; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer;
  }
  .sheet-item:active { background: #f8fafc; }
  .sheet-item.danger { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
  .sheet-ico { width: 30px; height: 30px; border-radius: 10px; background: #f1f5f9; display: grid; place-items: center; font-size: 0.9rem; }

  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head h1 { font-size: 1.45rem; }
  .page-sub { font-size: 0.8rem; }
  .page-head .filters { width: 100%; }
  #dash-filters .seg { width: 100%; overflow-x: auto; }
  #dash-filters .seg-btn { flex: 1 0 auto; }

  .app-banner { flex-wrap: wrap; padding: 14px 42px 14px 14px; gap: 10px; }
  .app-banner-text { flex: 1 1 calc(100% - 60px); }
  .app-banner .btn.primary { flex: 1 1 100%; margin-left: 0; }

  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px; border-radius: 18px; }
  .kpi-card.hero { padding: 18px; min-height: 152px; }
  .hero-value { font-size: 1.95rem; margin: 12px 0 10px; }
  .hero-chips { gap: 6px; }
  .hero-chip { padding: 6px 10px; font-size: 0.7rem; }
  .kpi-card .val { font-size: 1.12rem; }
  .kpi-card .kpi-ico { width: 30px; height: 30px; margin-bottom: 8px; }
  .kpis .kpi-card:nth-child(4) { grid-column: 1 / -1; }

  .insights { grid-template-columns: 1fr 1fr; gap: 10px; }
  .insights .insight-card:last-child { grid-column: 1 / -1; }
  .insight-value { font-size: 0.98rem; }

  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 15px; border-radius: 18px; margin-bottom: 12px; }
  .card h2 { font-size: 0.98rem; }
  .card-sub { font-size: 0.72rem; }
  .chart-box { height: 260px; }
  .chart-card .chart-box { height: 250px; }
  .share-list { gap: 10px; }

  .filters { gap: 8px; }
  #tx-filters input, #tx-filters select { flex: 1 1 44%; min-width: 0; }
  #tx-filters input[type="search"] { flex-basis: 100%; }
  #tx-filters .btn { flex: 1 1 40%; }

  .table-wrap { margin: 0 -2px; padding: 0 2px; }
  .table th, .table td { padding: 8px; }

  /* Транзакции — карточки */
  #tx-table thead { display: none; }
  #tx-table, #tx-table tbody { display: block; width: 100%; }
  #tx-table tr.tx-row {
    display: grid; grid-template-columns: 1fr auto; gap: 3px 12px;
    padding: 13px 14px; margin-bottom: 10px;
    border: 1px solid var(--line); border-radius: 16px; background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  }
  #tx-table tr.tx-row td { border: 0; padding: 0; }
  #tx-table tr.tx-row:hover { background: #fff; }
  .tx-date { grid-column: 1; font-size: 0.7rem; color: var(--muted); font-weight: 600; }
  .tx-cat { grid-column: 1; font-weight: 700; font-size: 0.86rem; }
  .tx-desc { grid-column: 1 / -1; color: var(--muted); font-size: 0.76rem; }
  .tx-amount { grid-column: 2; grid-row: 1 / 3; align-self: center; text-align: right; font-size: 0.98rem; }
  .tx-actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; padding-top: 7px; margin-top: 3px; border-top: 1px dashed var(--line); }
  .tx-actions .btn { padding: 4px 9px; font-size: 0.7rem; }

  /* Повторяющиеся — карточки */
  #rec-table thead { display: none; }
  #rec-table, #rec-table tbody { display: block; width: 100%; }
  #rec-table tr.rec-row {
    display: grid; grid-template-columns: 1fr auto; gap: 3px 12px;
    padding: 13px 14px; margin-bottom: 10px;
    border: 1px solid var(--line); border-radius: 16px; background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  }
  #rec-table tr.rec-row td { border: 0; padding: 0; }
  #rec-table tr.rec-row:hover { background: #fff; }
  .rec-type { grid-column: 1; font-size: 0.82rem; }
  .rec-cat { grid-column: 1; font-weight: 700; font-size: 0.88rem; }
  .rec-amount { grid-column: 2; grid-row: 1 / 3; align-self: center; text-align: right; font-size: 0.95rem; }
  .rec-day, .rec-period, .rec-next { grid-column: 1; font-size: 0.7rem; color: var(--muted); }
  .rec-desc { grid-column: 1 / -1; font-size: 0.76rem; color: var(--muted); }
  .rec-actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; padding-top: 7px; margin-top: 3px; border-top: 1px dashed var(--line); }
  .rec-actions .btn { padding: 4px 9px; font-size: 0.72rem; }

  .pager { gap: 8px; }
  .pager .btn { padding: 6px 10px; }

  /* Модалки — нижние шторки */
  .modal { align-items: flex-end; padding: 0; }
  .modal-card {
    width: 100%; max-width: 100%; max-height: 92dvh; overflow-y: auto;
    border-radius: 24px 24px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
    animation: ftSheetUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .modal-card h2 { font-size: 1.1rem; margin-bottom: 14px; }

  .toast { left: 14px; right: 14px; bottom: calc(92px + env(safe-area-inset-bottom)); text-align: center; max-width: none; }

  /* Приложение */
  .app-hero { grid-template-columns: 1fr; padding: 22px 18px; gap: 22px; border-radius: 22px; }
  .app-hero h2 { font-size: 1.55rem; }
  .app-hero p { font-size: 0.82rem; }
  .app-hero .row .btn { flex: 1 1 100%; }
  .phone-mock { width: 230px; transform: none; }
  .phone-screen { min-height: 320px; }
  .feature-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .feature-card { padding: 13px; border-radius: 16px; }
  .feature-card h3 { font-size: 0.8rem; }
  .feature-card p { font-size: 0.7rem; }
  .app-note { font-size: 0.78rem; }

  .auth-wrap { padding: 18px; align-items: center; }
  .auth-card { padding: 26px 22px; border-radius: 24px; }
  .brand { font-size: 1.35rem; }

  .dl { font-size: 0.85rem; }
  .inline-search { width: 100%; }
}

@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .hero-value { font-size: 1.72rem; }
  .kpi-card .val { font-size: 1rem; }
  .mnav-item { font-size: 0.52rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .sheet-grid { grid-template-columns: 1fr; }
}

@media (min-width: 901px) {
  .kpi-card:hover, .feature-card:hover, .insight-card:hover { transform: translateY(-2px); transition: transform 0.18s; }
  .app-hero .phone-mock { transition: transform 0.3s; }
  .app-hero .phone-mock:hover { transform: rotate(0deg) translateY(-4px); }
}

/* Тело в нативном приложении: чуть больше отступ снизу для жестов */
body.native-app .content { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
