/* ============================================================
   Семейный бюджет — стили.
   Архитектура: токенизированная дизайн-система, mobile-first,
   модульная разбивка по компонентам.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

/* ============================================================
   Дизайн-токены
   ============================================================ */
  :root {
    color-scheme: dark light;

    /* Шрифты */
    --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-heading: 'Outfit', 'DM Sans', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

    /* Цветовые токены — DARK по умолчанию */
    --bg: #070b14;
    --bg-elevated: #0f1524;
    --surface-1: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.07);
    --surface-3: rgba(255, 255, 255, 0.10);
    --surface-glass: rgba(20, 27, 45, 0.55);
    --surface-glass-strong: rgba(20, 27, 45, 0.85);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-soft: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text-1: #f1f5f9;
    --text-2: #cbd5e1;
    --text-3: #94a3b8;
    --text-4: #64748b;

    /* Бренд */
    --brand-50: #eef2ff;
    --brand-200: #c7d2fe;
    --brand-400: #818cf8;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-glow: rgba(99, 102, 241, 0.45);
    --teal-400: #2dd4bf;
    --teal-glow: rgba(45, 212, 191, 0.35);
    --violet-400: #a78bfa;

    --accent: var(--brand-400);
    --accent-hover: var(--brand-500);
    --accent-glow: var(--brand-glow);
    --accent-soft: rgba(129, 140, 248, 0.14);

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --danger: #fb7185;
    --danger-soft: rgba(251, 113, 133, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);

    /* Тени — многослойные для глубины */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md:
      0 4px 6px -1px rgba(0, 0, 0, 0.25),
      0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg:
      0 12px 24px -4px rgba(0, 0, 0, 0.35),
      0 4px 8px -4px rgba(0, 0, 0, 0.25);
    --shadow-xl:
      0 24px 48px -12px rgba(0, 0, 0, 0.45),
      0 8px 16px -8px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 0 1px var(--border-subtle), var(--shadow-lg);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);

    /* Радиусы */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --r-2xl: 28px;
    --r-full: 9999px;

    /* Блюр */
    --blur-glass: blur(20px) saturate(180%);

    /* Spacing — 4px base */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.25rem;
    --s-6: 1.5rem;
    --s-8: 2rem;
    --s-10: 2.5rem;
    --s-12: 3rem;

    /* Анимация */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast: 150ms;
    --t-base: 220ms;
    --t-slow: 360ms;

    /* Layout */
    --sidebar-w: 268px;
    --sidebar-gap: 1.25rem;
    --content-max: 1200px;

    /* Safe area */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    accent-color: var(--accent);
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
  }

  body.light-theme {
    color-scheme: light;
    --bg: #f6f7fb;
    --bg-elevated: #ffffff;
    --surface-1: rgba(15, 23, 42, 0.025);
    --surface-2: rgba(15, 23, 42, 0.05);
    --surface-3: rgba(15, 23, 42, 0.08);
    --surface-glass: rgba(255, 255, 255, 0.72);
    --surface-glass-strong: rgba(255, 255, 255, 0.92);

    --border-subtle: rgba(15, 23, 42, 0.06);
    --border-soft: rgba(15, 23, 42, 0.10);
    --border-strong: rgba(15, 23, 42, 0.16);

    --text-1: #0f172a;
    --text-2: #334155;
    --text-3: #64748b;
    --text-4: #94a3b8;

    --accent: var(--brand-600);
    --accent-hover: #4338ca;
    --accent-glow: rgba(79, 70, 229, 0.25);
    --accent-soft: rgba(79, 70, 229, 0.10);

    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.10);
    --danger: #e11d48;
    --danger-soft: rgba(225, 29, 72, 0.10);
    --warning: #d97706;
    --warning-soft: rgba(217, 119, 6, 0.10);

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.10), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
    --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.18), 0 8px 16px -8px rgba(15, 23, 42, 0.08);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }

/* ============================================================
   Reset
   ============================================================ */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; tab-size: 4; }
  body {
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.55;
    font-family: var(--font-body);
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    color: var(--text-1);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
  }
  img, svg, video, canvas { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { background: none; border: 0; cursor: pointer; }
  a { color: inherit; text-decoration: none; }
  ul, ol { list-style: none; }
  :focus { outline: none; }
  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
  }
  ::selection { background: var(--accent-glow); color: var(--text-1); }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background-color: rgba(148, 163, 184, 0.5); background-clip: padding-box; }

/* ============================================================
   База — фон, типографика, корневые элементы
   ============================================================ */
  /* Декоративный фон — mesh-градиенты без фото */
  body::before {
    content: '';
    position: fixed; inset: 0;
    z-index: -3;
    background:
      radial-gradient(ellipse 90% 70% at 8% -15%, rgba(99, 102, 241, 0.38), transparent 55%),
      radial-gradient(ellipse 70% 55% at 95% 5%, rgba(167, 139, 250, 0.28), transparent 50%),
      radial-gradient(ellipse 60% 45% at 50% 105%, rgba(45, 212, 191, 0.14), transparent 55%),
      var(--bg);
    transition: background var(--t-slow) var(--ease-out);
  }
  body::after {
    content: '';
    position: fixed; inset: 0;
    z-index: -2;
    background-image:
      linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: radial-gradient(ellipse 85% 75% at 50% 40%, black 15%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 40%, black 15%, transparent 72%);
    pointer-events: none;
  }
  body.light-theme::before {
    background:
      radial-gradient(ellipse 90% 70% at 8% -15%, rgba(99, 102, 241, 0.14), transparent 55%),
      radial-gradient(ellipse 70% 55% at 95% 5%, rgba(167, 139, 250, 0.12), transparent 50%),
      radial-gradient(ellipse 60% 45% at 50% 105%, rgba(45, 212, 191, 0.08), transparent 55%),
      var(--bg);
  }
  body.light-theme::after {
    background-image:
      linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
  }

  .ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
  }
  .ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    animation: orb-float 22s var(--ease-in-out) infinite;
  }
  .ambient-orb:nth-child(1) {
    width: min(42vw, 420px);
    height: min(42vw, 420px);
    top: -8%;
    left: -6%;
    background: rgba(99, 102, 241, 0.35);
    animation-delay: 0s;
  }
  .ambient-orb:nth-child(2) {
    width: min(36vw, 360px);
    height: min(36vw, 360px);
    top: 12%;
    right: -8%;
    background: rgba(167, 139, 250, 0.28);
    animation-delay: -7s;
    animation-duration: 26s;
  }
  .ambient-orb:nth-child(3) {
    width: min(30vw, 300px);
    height: min(30vw, 300px);
    bottom: -5%;
    left: 35%;
    background: rgba(45, 212, 191, 0.18);
    animation-delay: -14s;
    animation-duration: 30s;
  }
  @keyframes orb-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(2%, 3%) scale(1.04); }
    66% { transform: translate(-2%, 1%) scale(0.97); }
  }

  /* Типографика */
  h1, h2, h3, h4, h5 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-1);
  }
  h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
  h2 { font-size: clamp(1.25rem, 3.5vw, 1.6rem); }
  h3 { font-size: clamp(1rem, 2.8vw, 1.15rem); }
  p { color: var(--text-2); }

  strong { font-weight: 600; color: var(--text-1); }
  small { font-size: 0.85em; color: var(--text-3); }
  code, kbd, pre, samp { font-family: var(--font-mono); }

/* ============================================================
   Layout — сайдбар, главная разметка
   ============================================================ */
  .app-body, .app-container { min-height: 100vh; min-height: 100dvh; }

  /* ---------- Sidebar ---------- */
  .sidebar {
    position: fixed;
    top: var(--sidebar-gap);
    left: var(--sidebar-gap);
    bottom: var(--sidebar-gap);
    width: var(--sidebar-w);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-4);
    background: var(--surface-glass-strong);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-xl), var(--shadow-inset);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(calc(-100% - var(--sidebar-gap) * 2));
    transition: transform var(--t-base) var(--ease-out);
  }
  .sidebar.mobile-visible { transform: translateX(0); }

  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(8, 11, 20, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base) var(--ease-out);
  }
  .sidebar-overlay.active { opacity: 1; pointer-events: auto; }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-1) var(--s-2);
  }
  .sidebar-header h2 {
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
    color: var(--text-1);
    -webkit-text-fill-color: unset;
    background: none;
  }
  .brand-mark {
    display: inline-flex;
    width: 34px; height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--brand-500), var(--violet-400));
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
    flex-shrink: 0;
  }
  .brand-mark i { width: 18px; height: 18px; }
  .brand-text {
    background: linear-gradient(135deg, var(--text-1), var(--brand-200));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
  .sidebar-close {
    display: flex;
    width: 36px; height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    color: var(--text-2);
    transition: background var(--t-fast) var(--ease-out);
  }
  .sidebar-close:hover { background: var(--surface-2); }

  .sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    margin-bottom: var(--s-2);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    transition: background var(--t-fast) var(--ease-out);
  }
  .sidebar-user:hover { background: var(--surface-2); }
  .sidebar-username {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--s-2) 0;
  }
  .sidebar-section:not(:last-child) {
    border-bottom: 1px solid var(--border-subtle);
  }
  .sidebar-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-4);
    padding: var(--s-1) var(--s-3) var(--s-1);
    font-weight: 600;
  }
  .sidebar-actions { margin-top: auto; }

  .nav-btn {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    padding: 0.7rem 0.85rem;
    color: var(--text-2);
    font-size: 0.93rem;
    font-weight: 500;
    text-align: left;
    border-radius: var(--r-md);
    transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
    position: relative;
  }
  .nav-btn i { width: 18px; height: 18px; flex-shrink: 0; }
  .nav-btn:hover { background: var(--surface-2); color: var(--text-1); }
  .nav-btn:active { transform: scale(0.985); }
  .nav-btn.active {
    background: linear-gradient(135deg, var(--accent-soft), rgba(45, 212, 191, 0.06));
    color: var(--accent);
    font-weight: 600;
    border: 1px solid rgba(129, 140, 248, 0.18);
  }
  .nav-btn.active::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 25%;
    bottom: 25%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
  }
  .logout-btn { color: var(--danger); }
  .logout-btn:hover { background: var(--danger-soft); color: var(--danger); }

  /* ---------- Main content ---------- */
  .main-content {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--s-4);
    padding-top: calc(var(--s-4) + var(--safe-top));
    padding-bottom: calc(var(--s-8) + var(--safe-bottom));
    transition: margin var(--t-base) var(--ease-out);
  }

  /* Topbar — sticky на мобиле, обычный на десктопе */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-6);
    position: sticky;
    top: var(--safe-top);
    z-index: 50;
    padding: 0.35rem 0;
    transition: backdrop-filter var(--t-base);
  }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-width: 0;
    flex: 1;
  }
  .topbar-titles {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
  }
  .topbar-greeting {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-4);
    letter-spacing: 0.02em;
  }
  .topbar-page-title {
    font-family: var(--font-heading);
    font-size: clamp(1.15rem, 3vw, 1.45rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-shrink: 0;
  }
  .sync-pill {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--success);
    background: var(--success-soft);
    border: 1px solid rgba(52, 211, 153, 0.25);
    border-radius: var(--r-full);
  }
  .sync-pill::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse-dot 2s ease infinite;
  }
  @keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
  }
  @media (min-width: 720px) {
    .sync-pill { display: inline-flex; }
  }
  .theme-toggle-top {
    display: inline-flex;
    width: 40px; height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    color: var(--text-2);
    background: var(--surface-glass-strong);
    border: 1px solid var(--border-soft);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  }
  .theme-toggle-top:hover {
    background: var(--surface-3);
    color: var(--text-1);
    transform: translateY(-1px);
  }

  .hamburger {
    display: inline-flex;
    width: 44px; height: 44px;
    align-items: center;
    justify-content: center;
    color: var(--text-1);
    background: var(--surface-glass-strong);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    transition: transform var(--t-fast) var(--ease-out), background var(--t-fast);
  }
  .hamburger:hover { background: var(--surface-glass); transform: translateY(-1px); }
  .hamburger:active { transform: scale(0.95); }

  .topbar-user {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: 0.3rem 0.85rem 0.3rem 0.3rem;
    background: var(--surface-glass-strong);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-full);
    box-shadow: var(--shadow-md);
    font-weight: 500;
    font-size: 0.88rem;
    max-width: 60%;
    overflow: hidden;
  }
  .current-user {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

/* ============================================================
   Components
   ============================================================ */
  /* ---------- Glass Card ---------- */
  .glass-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)) , var(--surface-glass);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    padding: var(--s-5);
    box-shadow: var(--shadow-lg), var(--shadow-inset);
    transition:
      transform var(--t-base) var(--ease-out),
      box-shadow var(--t-base) var(--ease-out),
      border-color var(--t-base) var(--ease-out);
    position: relative;
    overflow: hidden;
  }
  .glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.14), transparent 40%, rgba(129, 140, 248, 0.12));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.65;
  }
  body.light-theme .glass-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.78)) , var(--surface-glass);
  }
  .glass-card.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl), var(--shadow-inset);
    border-color: var(--border-strong);
  }

  .card-icon {
    display: inline-flex;
    width: 44px; height: 44px;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-soft), rgba(45, 212, 191, 0.1));
    color: var(--accent);
    border-radius: var(--r-md);
    margin-bottom: var(--s-3);
    border: 1px solid rgba(129, 140, 248, 0.2);
  }
  .card-icon i { width: 20px; height: 20px; }

  /* ---------- Lucide icons ---------- */
  .lucide, [class*="lucide-"] {
    stroke-width: 1.75px !important;
    vertical-align: middle;
    flex-shrink: 0;
  }
  .input-icon { width: 15px; height: 15px; opacity: 0.7; }
  .btn-icon { width: 16px; height: 16px; }

  /* ---------- Buttons ---------- */
  .btn-primary,
  .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.93rem;
    line-height: 1;
    white-space: nowrap;
    border-radius: var(--r-md);
    padding: 0.7rem 1.2rem;
    min-height: 44px;
    user-select: none;
    -webkit-user-select: none;
    transition:
      transform var(--t-fast) var(--ease-out),
      box-shadow var(--t-fast) var(--ease-out),
      background var(--t-fast) var(--ease-out),
      filter var(--t-fast) var(--ease-out);
    position: relative;
    isolation: isolate;
  }
  .btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  }
  .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    filter: brightness(1.06);
  }
  .btn-primary:active { transform: translateY(0) scale(0.98); }
  .btn-primary:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
  }
  .btn-primary.loading { color: transparent; pointer-events: none; }
  .btn-primary.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px; height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .btn-secondary {
    background: var(--surface-2);
    color: var(--text-1);
    border: 1px solid var(--border-soft);
  }
  .btn-secondary:hover {
    background: var(--surface-3);
    transform: translateY(-1px);
    border-color: var(--border-strong);
  }
  .btn-secondary:active { transform: scale(0.98); }

  .btn-compact { padding: 0.45rem 0.85rem; font-size: 0.82rem; min-height: 36px; }

  .btn-icon-only {
    display: inline-flex;
    width: 40px; height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    color: var(--text-2);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), color var(--t-fast);
  }
  .btn-icon-only:hover { background: var(--surface-3); color: var(--text-1); transform: translateY(-1px); }
  .btn-icon-only:active { transform: scale(0.95); }
  .btn-icon-only i { width: 18px; height: 18px; }
  .btn-icon-only.delete-btn { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
  .btn-icon-only.delete-btn:hover { background: rgba(251, 113, 133, 0.22); }

  /* ---------- Inputs ---------- */
  .input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: var(--s-3);
  }
  .input-group label {
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }

  input[type="text"], input[type="number"], input[type="password"],
  input[type="email"], input[type="tel"], input[type="search"],
  input[type="date"], input[type="datetime-local"], input[type="time"],
  select, textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.7rem 0.95rem;
    font-family: var(--font-body);
    font-size: 1rem;       /* iOS не зумит при ≥16px */
    line-height: 1.5;
    color: var(--text-1);
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    -webkit-appearance: none;
    appearance: none;
    transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  }
  input:hover, select:hover, textarea:hover {
    background: var(--surface-3);
  }
  input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-3);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }
  input::placeholder, textarea::placeholder {
    color: var(--text-4);
    opacity: 0.85;
  }
  textarea { resize: vertical; min-height: 84px; line-height: 1.55; }

  input[type="number"]::-webkit-inner-spin-button,
  input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none; margin: 0;
  }
  input[type="number"] { -moz-appearance: textfield; }

  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    padding-right: 2.5rem;
    cursor: pointer;
  }
  body.light-theme select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  }

  /* ---------- Avatar ---------- */
  .avatar-container {
    display: flex;
    width: 38px; height: 38px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand-400), var(--teal-400));
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    padding: 2px;
  }
  .avatar-container > img,
  .avatar-container > .avatar-inner {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-elevated);
  }
  .avatar-container.small { width: 28px; height: 28px; }
  .avatar-container img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
  .avatar-placeholder {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--surface-2);
    width: 100%; height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .avatar-upload { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }
  .avatar-preview {
    width: 88px; height: 88px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--s-2);
    border: 2px solid var(--border-subtle);
  }
  .avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
  #avatarFileInput {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* ---------- Section title ---------- */
  .section-heading {
    display: flex;
    align-items: flex-start;
    gap: var(--s-4);
    margin-bottom: var(--s-6);
  }
  .section-heading-icon {
    display: flex;
    width: 48px; height: 48px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--r-lg);
    background: linear-gradient(135deg, var(--accent-soft), rgba(45, 212, 191, 0.08));
    border: 1px solid rgba(129, 140, 248, 0.2);
    color: var(--accent);
  }
  .section-heading-icon i { width: 22px; height: 22px; }
  .section-title {
    font-size: clamp(1.35rem, 3.5vw, 1.65rem);
    margin: 0 0 0.25rem;
    letter-spacing: -0.03em;
  }
  .section-desc {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-3);
    line-height: 1.45;
  }
  .section-title-standalone {
    font-size: clamp(1.35rem, 3.5vw, 1.65rem);
    margin-bottom: var(--s-6);
    letter-spacing: -0.03em;
  }
  .subsection-title {
    font-size: 1rem;
    font-weight: 600;
    margin: var(--s-5) 0 var(--s-3);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-1);
  }
  .subsection-title i { width: 17px; height: 17px; color: var(--accent); }

  .big-number {
    font-family: var(--font-mono);
    font-size: clamp(1.4rem, 4.5vw, 2.1rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-1);
    letter-spacing: -0.02em;
    margin-top: var(--s-1);
    font-variant-numeric: tabular-nums;
  }
  .big-number.deadline-text,
  .deadline-text {
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
    font-weight: 600;
    line-height: 1.35;
    font-family: var(--font-body);
    letter-spacing: normal;
  }

  /* ---------- Dashboard ---------- */
  .page-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-5);
    margin-bottom: var(--s-6);
    padding: var(--s-6);
  }
  .page-hero-title {
    font-size: clamp(1.35rem, 3.5vw, 1.85rem);
    margin: 0 0 0.35rem;
    letter-spacing: -0.03em;
  }
  .page-hero-sub {
    margin: 0;
    color: var(--text-3);
    font-size: 0.92rem;
    max-width: 36ch;
  }
  .quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
  }
  .quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-full);
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  }
  .quick-action-btn i { width: 15px; height: 15px; }
  .quick-action-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgba(129, 140, 248, 0.3);
    transform: translateY(-1px);
  }
  .tab-content.tab-active {
    animation: tab-in 0.38s var(--ease-out) both;
  }
  @keyframes tab-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .dashboard-grid .glass-card h3 {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 0.15rem;
  }
  .dashboard-grid .glass-card.highlight-card {
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.12), rgba(45, 212, 191, 0.06)), var(--surface-glass);
  }
  .dashboard-grid .glass-card.highlight-card .big-number {
    background: linear-gradient(135deg, var(--text-1), var(--brand-200));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-4);
    margin-bottom: var(--s-6);
  }
  .charts-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-4);
    margin-bottom: var(--s-4);
  }
  .chart-container {
    height: 280px;
    padding: var(--s-4);
  }
  .chart-container canvas { max-width: 100%; }

  .progress-bar-container {
    background: var(--surface-3);
    border-radius: var(--r-full);
    height: 8px;
    margin-top: var(--s-3);
    overflow: hidden;
    position: relative;
  }
  .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #c084fc);
    border-radius: inherit;
    transition: width 0.6s var(--ease-out);
    position: relative;
  }
  .progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    animation: shimmer 2.4s infinite;
  }
  @keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
  }

  /* ---------- Planner ---------- */
  .plan-controls {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-full);
    margin-bottom: var(--s-4);
  }
  .period-btn {
    color: var(--text-3);
    padding: 0.5rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--r-full);
    transition: background var(--t-fast), color var(--t-fast);
    min-height: 36px;
  }
  .period-btn:hover { color: var(--text-1); }
  .period-btn.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px var(--accent-glow);
  }
  .task-form { margin-bottom: var(--s-5); }
  .datetime-row {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: var(--s-3);
  }

  .year-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-3);
  }
  .year-month-card {
    text-align: center;
    padding: var(--s-4);
    background: var(--surface-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: transform var(--t-fast) var(--ease-out), background var(--t-fast), border-color var(--t-fast);
  }
  .year-month-card:hover {
    transform: translateY(-3px);
    background: var(--surface-glass-strong);
    border-color: var(--border-strong);
  }
  .month-name {
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font-heading);
    margin-bottom: var(--s-1);
  }
  .task-count { font-size: 0.8rem; color: var(--text-3); }

  .month-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: var(--s-2);
    background: var(--surface-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
  }
  .day-name {
    text-align: center;
    font-weight: 600;
    color: var(--text-3);
    padding: var(--s-2) 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .day-cell {
    background: var(--surface-1);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: var(--s-2);
    min-height: 56px;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .day-cell:hover { background: var(--accent-soft); }
  .day-cell.today {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
  .day-cell.empty { background: transparent; cursor: default; pointer-events: none; }
  .day-num { font-weight: 600; font-size: 0.9rem; }
  .task-badge {
    align-self: flex-end;
    padding: 1px 8px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--r-full);
    font-size: 0.68rem;
    font-weight: 700;
    box-shadow: 0 1px 3px var(--accent-glow);
  }

  .back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    background: var(--surface-1);
    border: 1px solid var(--border-soft);
    color: var(--text-2);
    border-radius: var(--r-md);
    font-size: 0.88rem;
    margin-bottom: var(--s-4);
    cursor: pointer;
    transition: background var(--t-fast), transform var(--t-fast);
  }
  .back-button:hover { background: var(--surface-2); transform: translateX(-2px); }
  .back-button i { width: 15px; height: 15px; }
  .day-title { margin-bottom: var(--s-4); text-transform: capitalize; }
  .empty-state {
    color: var(--text-3);
    padding: var(--s-6) var(--s-4);
    text-align: center;
    font-size: 0.92rem;
  }

  .day-task-list { display: flex; flex-direction: column; gap: var(--s-3); }
  .day-task-item {
    background: var(--surface-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: transform var(--t-fast) var(--ease-out), border-color var(--t-fast);
  }
  .day-task-item:hover { transform: translateY(-2px); border-color: var(--border-strong); }
  .task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--s-2);
    flex-wrap: wrap;
  }
  .task-header strong { font-size: 1.05rem; font-family: var(--font-heading); }
  .task-description {
    font-size: 0.9rem;
    color: var(--text-3);
    padding: 0.4rem 0.8rem;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
  }
  .day-task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.82rem;
    color: var(--text-3);
  }
  .day-task-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
  }
  .day-task-meta i { width: 13px; height: 13px; opacity: 0.7; }
  .task-actions { display: flex; gap: 0.4rem; justify-content: flex-end; margin-top: 2px; }

  /* ---------- Status badges ---------- */
  .status-badge {
    padding: 0.2rem 0.7rem;
    border-radius: var(--r-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .status-in-progress { background: var(--warning-soft); color: var(--warning); }
  .status-done { background: var(--success-soft); color: var(--success); }

  /* ---------- Budget ---------- */
  .budget-form { display: flex; flex-direction: column; gap: 0.1rem; }
  .expenses-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
  }
  .add-expense-row {
    display: grid;
    grid-template-columns: 1fr 110px 44px;
    gap: var(--s-2);
    align-items: end;
    margin-top: var(--s-2);
  }
  .add-expense-row .btn-primary {
    width: 44px; height: 44px;
    padding: 0;
    border-radius: var(--r-md);
  }
  .custom-expense-row {
    display: grid;
    grid-template-columns: 1fr auto 32px;
    gap: var(--s-3);
    align-items: center;
    padding: 0.55rem 0.85rem;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    margin-bottom: 0.4rem;
  }
  .custom-expense-row .ce-name { font-weight: 500; }
  .custom-expense-row .ce-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-1);
    font-variant-numeric: tabular-nums;
  }
  .custom-expense-row .btn-icon-only { width: 32px; height: 32px; }
  .custom-expense-row .btn-icon-only i { width: 14px; height: 14px; }
  .empty-row { color: var(--text-4); font-size: 0.88rem; padding: 0.5rem 0; }

  .percentage-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: var(--s-2) 0;
  }
  .percent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: 0.4rem 0.85rem;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
  }
  .percent-label {
    font-size: 0.92rem;
    color: var(--text-2);
    font-weight: 500;
  }
  .percent-input-wrap {
    position: relative;
    flex-shrink: 0;
  }
  .percent-input {
    width: 92px !important;
    text-align: right;
    padding: 0.45rem 1.7rem 0.45rem 0.6rem !important;
    min-height: 40px !important;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
  }
  .percent-suffix {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 0.88rem;
    pointer-events: none;
  }

  .remainder-result {
    margin: var(--s-4) 0;
    padding: var(--s-4);
    text-align: center;
    background: linear-gradient(135deg, var(--accent-soft), transparent);
    border: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
  }
  .distribution-results {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }
  .dist-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.9rem;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    font-size: 0.93rem;
  }
  .dist-row b { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  .partner-income { font-size: 0.88rem; color: var(--text-3); margin: var(--s-2) 0; }

  /* ---------- Smart Import ---------- */
  .import-card { margin-top: var(--s-4); }
  .import-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
  }
  .import-subtitle {
    font-size: 0.86rem;
    color: var(--text-3);
    margin-top: 0.25rem;
    line-height: 1.5;
  }
  .import-help {
    background: var(--accent-soft);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    margin-bottom: var(--s-4);
    font-size: 0.9rem;
    animation: slideDown var(--t-base) var(--ease-out);
  }
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .import-help h4 {
    font-size: 0.85rem;
    margin-bottom: var(--s-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
  }
  .import-help details {
    margin-bottom: 0.4rem;
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    transition: background var(--t-fast);
  }
  .import-help details[open] { background: var(--surface-2); }
  .import-help summary {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    list-style: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
  }
  .import-help summary::before {
    content: '';
    width: 0; height: 0;
    border-left: 5px solid var(--text-3);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform var(--t-fast);
  }
  .import-help details[open] summary::before { transform: rotate(90deg); }
  .import-help summary::-webkit-details-marker { display: none; }
  .import-help ol {
    padding: var(--s-2) var(--s-2) var(--s-3) 2.5rem;
    line-height: 1.7;
    list-style: decimal;
  }
  .import-help li { margin-bottom: 0.15rem; color: var(--text-2); }
  .hint-tip {
    margin: 0.5rem 0.85rem 0.85rem;
    padding: 0.5rem 0.75rem;
    background: var(--warning-soft);
    border-left: 3px solid var(--warning);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    color: var(--text-2);
    line-height: 1.5;
  }
  .import-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: var(--s-3);
    padding-top: var(--s-3);
    border-top: 1px solid var(--border-subtle);
    color: var(--text-3);
    font-size: 0.82rem;
    line-height: 1.5;
  }
  .import-note i { width: 16px; height: 16px; color: var(--success); flex-shrink: 0; margin-top: 2px; }

  .import-dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--r-lg);
    padding: var(--s-6) var(--s-4);
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  }
  .import-dropzone i {
    width: 38px; height: 38px;
    color: var(--accent);
    margin-bottom: var(--s-2);
  }
  .import-dropzone:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
  .import-dropzone.dragover {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: scale(1.01);
  }
  .dz-title { font-weight: 600; font-size: 1rem; }
  .dz-hint { font-size: 0.85rem; color: var(--text-3); }

  .import-preview { margin-top: var(--s-4); animation: slideDown var(--t-base) var(--ease-out); }
  .import-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    align-items: center;
    margin-bottom: var(--s-3);
    font-size: 0.95rem;
  }
  .dup-info { color: var(--warning); font-size: 0.85rem; }
  .import-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    max-height: 50vh;
    background: var(--surface-1);
  }
  .import-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 540px;
  }
  .import-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-glass-strong);
    backdrop-filter: var(--blur-glass);
  }
  .import-table th, .import-table td {
    padding: 0.55rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
  }
  .import-table th {
    font-weight: 600;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
  }
  .import-table tbody tr { transition: background var(--t-fast); }
  .import-table tbody tr:hover { background: var(--surface-2); }
  .import-table tr.dup { opacity: 0.42; }
  .td-date {
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
  }
  .td-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .td-amount.pos { color: var(--success); }
  .td-amount.neg { color: var(--danger); }
  .td-desc {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .td-cat select.cat-select {
    min-height: 36px;
    padding: 0.35rem 1.8rem 0.35rem 0.6rem;
    font-size: 0.85rem;
    border-radius: var(--r-sm);
  }
  .import-actions {
    display: flex;
    gap: var(--s-2);
    justify-content: flex-end;
    margin-top: var(--s-4);
    flex-wrap: wrap;
  }
  .column-picker {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
  }
  .col-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: var(--s-2);
    align-items: center;
  }
  .col-row label { font-weight: 500; font-size: 0.9rem; color: var(--text-2); }

  /* ---------- Transactions ---------- */
  .transactions-card { margin-top: var(--s-4); }
  .transactions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
    margin-bottom: var(--s-3);
  }
  .tx-controls { display: flex; gap: 0.4rem; align-items: center; }
  .tx-select {
    min-height: 38px;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    font-size: 0.85rem;
    width: auto;
    min-width: 160px;
  }
  .tx-totals { margin-bottom: var(--s-4); }
  .tx-totals-row {
    display: flex;
    gap: var(--s-2);
    margin-bottom: 0.6rem;
  }
  .tx-total-pill {
    padding: 0.5rem 0.95rem;
    border-radius: var(--r-md);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
  }
  .tx-total-pill.in { background: var(--success-soft); color: var(--success); }
  .tx-total-pill.out { background: var(--danger-soft); color: var(--danger); }
  .tx-cat-totals { display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .tx-cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-full);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
  }
  .tx-cat-chip:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    transform: translateY(-1px);
  }
  .tx-cat-name { color: var(--text-2); }
  .tx-cat-sum {
    font-family: var(--font-mono);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }
  .tx-cat-sum.pos { color: var(--success); }
  .tx-cat-sum.neg { color: var(--danger); }

  .tx-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 4px;
  }
  .tx-item {
    display: grid;
    grid-template-columns: 36px 1fr auto 32px;
    gap: 0.6rem;
    align-items: center;
    padding: 0.6rem 0.85rem;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  }
  .tx-item:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
  }
  .tx-emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    width: 36px; height: 36px;
    background: var(--surface-2);
    border-radius: var(--r-md);
  }
  .tx-main { min-width: 0; }
  .tx-desc {
    font-weight: 500;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-1);
  }
  .tx-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
  }
  .tx-cat-select {
    min-height: 26px !important;
    padding: 0.15rem 1.5rem 0.15rem 0.4rem !important;
    font-size: 0.74rem !important;
    width: auto !important;
    background: var(--surface-2);
  }
  .tx-amount {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .tx-amount.pos { color: var(--success); }
  .tx-amount.neg { color: var(--danger); }
  .tx-delete { width: 32px !important; height: 32px !important; }
  .tx-delete i { width: 13px !important; height: 13px !important; }

  /* ---------- Notes ---------- */
  .notes-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-4);
  }
  .notes-sidebar {
    background: var(--surface-glass);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    min-height: 280px;
    max-height: 50vh;
    box-shadow: var(--shadow-md);
  }
  .notes-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .notes-search {
    width: 100%;
    min-height: 40px;
    padding: 0.55rem 0.85rem 0.55rem 2.25rem;
    font-size: 0.88rem;
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 0.7rem center;
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
  }
  .notes-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }
  .notes-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 0 4px;
  }
  .notes-empty {
    color: var(--text-3);
    font-size: 0.88rem;
    padding: var(--s-4);
    text-align: center;
  }
  .note-item {
    padding: 0.65rem 0.85rem;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  }
  .note-item:hover { background: var(--surface-2); transform: translateX(2px); }
  .note-item.active {
    background: var(--accent-soft);
    border-color: var(--accent);
  }
  .note-item-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .note-item-preview {
    font-size: 0.78rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .notes-editor-container {
    background: var(--surface-glass);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    min-height: 60vh;
    box-shadow: var(--shadow-md);
  }
  .notes-editor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: var(--s-3);
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--border-subtle);
  }
  .note-title-input {
    flex: 1;
    min-width: 0;
    background: transparent !important;
    border: none !important;
    font-family: var(--font-heading);
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    padding: 0.25rem 0 !important;
    min-height: auto !important;
    box-shadow: none !important;
  }
  .notes-editor-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  .format-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    margin-bottom: var(--s-3);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
  }
  .format-toolbar button {
    width: 36px; height: 36px;
    color: var(--text-2);
    border-radius: var(--r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--t-fast), color var(--t-fast);
  }
  .format-toolbar button:hover { background: var(--surface-3); color: var(--text-1); }
  .format-toolbar button:active,
  .format-toolbar button.active {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .format-toolbar i { width: 16px; height: 16px; }
  .toolbar-sep {
    width: 1px;
    background: var(--border-subtle);
    margin: 4px 4px;
    align-self: stretch;
  }

  .editor-wrapper {
    flex: 1;
    display: flex;
    min-height: 280px;
  }
  .rich-editor {
    flex: 1;
    outline: none;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-1);
    padding: var(--s-2) var(--s-1);
    word-wrap: break-word;
    overflow-y: auto;
    min-height: 260px;
  }
  .rich-editor:focus { outline: none; }
  .rich-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-4);
    pointer-events: none;
  }
  .rich-editor h1, .rich-editor h2, .rich-editor h3 {
    margin: 1em 0 0.4em;
    line-height: 1.3;
  }
  .rich-editor h1 { font-size: 1.5rem; }
  .rich-editor h2 { font-size: 1.25rem; }
  .rich-editor h3 { font-size: 1.1rem; }
  .rich-editor p { margin-bottom: 0.6em; }
  .rich-editor ul, .rich-editor ol { padding-left: 1.5rem; margin-bottom: 0.7em; }
  .rich-editor ol { list-style: decimal; }
  .rich-editor ul { list-style: disc; }
  .rich-editor li { margin-bottom: 0.25em; }
  .rich-editor blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.4rem 0.9rem;
    margin: 0.6rem 0;
    color: var(--text-2);
    background: var(--accent-soft);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
  }
  .rich-editor code {
    font-family: var(--font-mono);
    background: var(--surface-3);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
  }
  .rich-editor a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .mobile-format-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: var(--surface-glass-strong);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border-top: 1px solid var(--border-soft);
    padding: 0.5rem 0.75rem;
    padding-bottom: calc(0.5rem + var(--safe-bottom));
    z-index: 80;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
  }
  .mobile-format-bar button {
    background: var(--surface-2);
    color: var(--text-1);
    width: 42px; height: 42px;
    flex-shrink: 0;
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--t-fast);
  }
  .mobile-format-bar button:active {
    background: var(--accent-soft);
    color: var(--accent);
  }

  /* ---------- Settings ---------- */
  .settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-4);
  }
  .settings-card { display: flex; flex-direction: column; gap: var(--s-3); }
  .settings-user { font-size: 0.92rem; color: var(--text-3); }
  .switch-user-container { margin-top: var(--s-2); }

  /* ---------- Login ---------- */
  .login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--s-5);
    position: relative;
  }
  .login-shell {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
  }
  .login-brand-panel {
    text-align: center;
    padding: 0 var(--s-2);
  }
  .login-brand-panel .brand-mark {
    width: 56px; height: 56px;
    border-radius: var(--r-lg);
    margin: 0 auto var(--s-4);
  }
  .login-brand-panel .brand-mark i { width: 28px; height: 28px; }
  .login-tagline {
    font-size: 0.88rem;
    color: var(--text-3);
    line-height: 1.5;
    max-width: 32ch;
    margin: 0.5rem auto 0;
  }
  .login-card {
    width: 100%;
    text-align: left;
    padding: var(--s-6);
    box-shadow: var(--shadow-xl);
  }
  .login-header { margin-bottom: var(--s-5); text-align: center; }
  .login-title {
    font-size: 1.65rem;
    margin: 0 0 0.3rem;
    background: linear-gradient(135deg, var(--text-1), var(--brand-200));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
  .login-subtitle { color: var(--text-3); font-size: 0.9rem; }
  .login-form { display: flex; flex-direction: column; gap: var(--s-3); }
  .login-btn { width: 100%; margin-top: var(--s-1); }
  .login-footer { margin-top: var(--s-4); min-height: 1.4rem; text-align: center; }
  .password-wrap {
    position: relative;
    display: flex;
    align-items: center;
  }
  .password-wrap input { padding-right: 2.75rem; }
  .password-toggle {
    position: absolute;
    right: 0.5rem;
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-4);
    border-radius: var(--r-sm);
    transition: color var(--t-fast), background var(--t-fast);
  }
  .password-toggle:hover { color: var(--text-2); background: var(--surface-2); }
  .login-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-2);
    margin-top: var(--s-2);
  }
  .login-feature {
    text-align: center;
    padding: var(--s-3) var(--s-2);
    border-radius: var(--r-lg);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
  }
  .login-feature i {
    width: 18px; height: 18px;
    color: var(--accent);
    margin-bottom: 0.35rem;
  }
  .login-feature span {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-3);
    line-height: 1.3;
  }
  .login-presentations-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin-top: var(--s-3);
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--r-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
    width: 100%;
  }
  .login-presentations-link i { width: 16px; height: 16px; opacity: 0.8; }
  .login-presentations-link:hover {
    color: var(--accent);
    border-color: rgba(129, 140, 248, 0.35);
    background: var(--accent-soft);
  }

  /* ---------- Messages / Toast ---------- */
  .error-message {
    color: var(--danger);
    font-size: 0.85rem;
    min-height: 1.1em;
    line-height: 1.4;
  }
  .attempts-info {
    color: var(--warning);
    font-size: 0.85rem;
    min-height: 1.1em;
  }
  .toast-host {
    position: fixed;
    top: calc(var(--safe-top) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: calc(100% - 2rem);
  }
  .toast {
    background: var(--surface-glass-strong);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 0.7rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    color: var(--text-1);
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
    transition: opacity var(--t-base), transform var(--t-base) var(--ease-spring);
  }
  .toast.show { opacity: 1; transform: translateY(0) scale(1); }
  .toast-error { border-left: 3px solid var(--danger); }
  .toast-info { border-left: 3px solid var(--accent); }
  .toast-success { border-left: 3px solid var(--success); }

/* ============================================================
   Responsive
   ============================================================ */
  /* Планшет ≥720 */
  @media (min-width: 720px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: var(--s-5); }
    .charts-row { grid-template-columns: repeat(2, 1fr); gap: var(--s-5); }
    .expenses-grid { grid-template-columns: 1fr 1fr; }
    .year-grid { grid-template-columns: repeat(3, 1fr); }
    .day-cell { min-height: 70px; padding: 0.7rem; }
    .day-num { font-size: 0.92rem; }
    .day-name { font-size: 0.78rem; }
    .settings-grid { grid-template-columns: repeat(2, 1fr); }
    .notes-layout {
      grid-template-columns: 290px 1fr;
      height: calc(100vh - 11rem);
      height: calc(100dvh - 11rem);
    }
    .notes-sidebar { max-height: none; }
  }

  /* Десктоп ≥1024 */
  @media (min-width: 1024px) {
    .sidebar { transform: translateX(0); }
    .sidebar-overlay { display: none; }
    .hamburger, .sidebar-close { display: none; }

    .main-content {
      margin-left: calc(var(--sidebar-w) + var(--sidebar-gap) * 2);
      padding: var(--s-6) var(--s-8);
    }
    .topbar { position: static; padding: 0; margin-bottom: var(--s-6); }
    .dashboard-grid {
      grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    .year-grid { grid-template-columns: repeat(4, 1fr); }
    .day-cell { min-height: 78px; }
    .add-expense-row { grid-template-columns: 2fr 1fr 44px; }
  }

  /* Большой экран ≥1280 */
  @media (min-width: 1280px) {
    .charts-row { grid-template-columns: 1fr 1fr; }
    .chart-container { height: 320px; }
  }

  /* Мобильная плавающая панель — только на узких экранах при открытой заметке */
  @media (max-width: 1023px) {
    body.note-open .mobile-format-bar { display: flex; }
    body.note-open { padding-bottom: 64px; }
  }

  /* Мобильные доводки ≤719 */
  @media (max-width: 719px) {
    :root { --sidebar-gap: 1rem; }

    .glass-card { padding: var(--s-4); }
    .section-title { margin-bottom: var(--s-4); }

    .dashboard-grid { gap: var(--s-3); }
    .big-number { font-size: 1.4rem; }
    .card-icon {
      width: 38px; height: 38px;
      margin-bottom: 0.5rem;
      border-radius: var(--r-sm);
    }
    .card-icon i { width: 18px; height: 18px; }
    .glass-card h3 { font-size: 1rem; }

    .chart-container { height: 220px; padding: var(--s-3); }

    .plan-controls { width: 100%; }
    .period-btn { flex: 1; padding: 0.45rem 0.5rem; font-size: 0.85rem; }

    .month-calendar { padding: 0.3rem; gap: 3px; }
    .day-cell { padding: 0.4rem 0.3rem; min-height: 46px; }
    .day-num { font-size: 0.8rem; }
    .day-name { font-size: 0.7rem; padding: 0.25rem 0; }
    .task-badge { font-size: 0.62rem; padding: 0 5px; }

    .add-expense-row { grid-template-columns: 1fr 100px 44px; gap: 0.4rem; }
    .percent-row { padding: 0.35rem 0.7rem; }
    .percent-input { width: 80px !important; }

    .notes-sidebar { max-height: 38vh; min-height: auto; }
    .notes-editor-container { min-height: 56vh; }
    .note-title-input { font-size: 1.1rem !important; }
    .format-toolbar { gap: 1px; }
    .format-toolbar button { width: 34px; height: 34px; }
    .toolbar-sep { display: none; }

    .import-actions { flex-direction: column-reverse; }
    .import-actions button { width: 100%; }
    .col-row { grid-template-columns: 1fr; gap: 0.25rem; }
    .col-row label { font-size: 0.85rem; color: var(--text-3); }

    .tx-item { grid-template-columns: 30px 1fr auto 26px; gap: 0.5rem; padding: 0.55rem 0.65rem; }
    .tx-emoji { width: 30px; height: 30px; font-size: 1.05rem; }
    .tx-delete { width: 26px !important; height: 26px !important; }
    .tx-delete i { width: 12px !important; height: 12px !important; }
    .tx-cat-select {
      font-size: 0.7rem !important;
      max-width: 110px;
      padding: 0.1rem 1.4rem 0.1rem 0.35rem !important;
    }
    .tx-amount { font-size: 0.88rem; }
    .tx-controls { width: 100%; }
    .tx-select { flex: 1; min-width: 0; }
    .transactions-header { flex-direction: column; align-items: stretch; }

    .topbar-user { max-width: 65%; }
  }

  /* Очень узкие экраны (iPhone SE, Galaxy small) */
  @media (max-width: 380px) {
    :root { --sidebar-gap: 0.5rem; }
    .main-content { padding: 0.6rem; padding-top: calc(0.6rem + var(--safe-top)); }
    .glass-card { padding: 0.85rem; border-radius: var(--r-lg); }
    .add-expense-row { grid-template-columns: 1fr 80px 40px; gap: 0.3rem; }
    .add-expense-row .btn-primary { width: 40px; height: 40px; }
    .datetime-row { grid-template-columns: 1fr 80px; }
    .format-toolbar button { width: 30px; height: 30px; }
    .topbar-user { font-size: 0.78rem; max-width: 60%; }
    .avatar-container.small { width: 22px; height: 22px; }
    .section-title { font-size: 1.2rem; }
    .big-number { font-size: 1.2rem; }
    .day-cell { min-height: 38px; padding: 0.3rem 0.2rem; }
    .day-num { font-size: 0.74rem; }
    .nav-btn { padding: 0.6rem 0.75rem; }
  }

  /* Tablet/desktop — улучшенные тач-таргеты на iPad */
  @media (hover: none) and (pointer: coarse) {
    .glass-card.hover-lift:hover { transform: none; }
    .nav-btn:hover { transform: none; }
    .year-month-card:hover { transform: none; }
    .tx-item:hover { transform: none; }
  }

/* ============================================================
   Презентации
   ============================================================ */
.presentations-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.presentations-subtitle {
  margin: 0.35rem 0 0;
  color: var(--text-3);
  font-size: 0.9rem;
}

.presentations-open-public {
  white-space: nowrap;
}

.presentations-layout {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .presentations-layout {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: start;
  }
}

.presentations-upload-card h3,
.presentations-list-card h3 {
  margin: 0 0 1rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
}

.presentation-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  padding: 1.25rem;
  border-radius: var(--r-xl);
  border: 2px dashed var(--border-soft);
  background: var(--surface-1);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  text-align: center;
}

.presentation-dropzone:hover,
.presentation-dropzone.dragover {
  border-color: rgba(129, 140, 248, 0.55);
  background: var(--accent-soft);
}

.presentation-dropzone-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.presentation-dropzone-title {
  margin: 0;
  font-weight: 600;
  color: var(--text-1);
}

.presentation-dropzone-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-4);
}

.presentation-file-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.presentation-file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.presentation-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.presentation-file-size {
  font-size: 0.75rem;
  color: var(--text-4);
}

.presentations-form-grid {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

@media (min-width: 720px) {
  .presentations-form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.presentations-form-full {
  grid-column: 1 / -1;
}

.presentations-form-grid textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
  background: var(--surface-1);
  color: var(--text-1);
  padding: 0.65rem 0.8rem;
  font: inherit;
}

.presentations-publish-btn {
  width: 100%;
  margin-top: 1rem;
}

.presentations-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.presentations-loading {
  font-size: 0.8rem;
  color: var(--text-4);
}

.presentations-admin-list {
  display: grid;
  gap: 0.75rem;
}

.presentations-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-4);
  font-size: 0.9rem;
}

.presentation-admin-card {
  padding: 1rem;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
}

.presentation-admin-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.presentation-admin-top h4 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
}

.presentation-admin-top p {
  margin: 0;
  color: var(--text-3);
  font-size: 0.82rem;
  line-height: 1.45;
}

.presentation-admin-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
  font-size: 0.72rem;
  color: var(--text-4);
}

.presentation-tag {
  padding: 0.15rem 0.5rem;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
}

.presentation-admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.presentation-admin-footer code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-4);
  overflow: hidden;
  text-overflow: ellipsis;
}

.presentation-delete-btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  background: var(--danger-soft);
  color: var(--danger);
}

.success-message {
  color: var(--success) !important;
  margin-top: 0.75rem;
}

/* Публичная галерея презентаций */
body.public-presentations {
  min-height: 100vh;
  padding: 1.5rem 1rem 3rem;
}
.public-wrap { max-width: 1000px; margin: 0 auto; }
.public-header {
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.public-header h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 0 0 0.35rem;
  letter-spacing: -0.03em;
}
.public-header p { color: var(--text-3); margin: 0; }
.presentations-public-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .presentations-public-grid { grid-template-columns: repeat(2, 1fr); }
}
.presentation-public-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  padding: 1.35rem;
  border-radius: var(--r-xl);
  background: var(--surface-glass);
  border: 1px solid var(--border-soft);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  box-shadow: var(--shadow-lg);
  transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s;
  position: relative;
  overflow: hidden;
  min-height: 140px;
}
.presentation-public-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-500), var(--teal-400));
  opacity: 0;
  transition: opacity 0.25s;
}
.presentation-public-card:hover {
  transform: translateY(-4px);
  border-color: rgba(129, 140, 248, 0.4);
  box-shadow: var(--shadow-xl);
}
.presentation-public-card:hover::before { opacity: 1; }
.presentation-public-icon {
  display: inline-flex;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 0.85rem;
  font-size: 1.1rem;
}
.presentation-public-card h2 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  line-height: 1.35;
}
.presentation-public-card p {
  margin: 0;
  color: var(--text-3);
  font-size: 0.875rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.presentation-public-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.85rem;
}
.presentation-public-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-3);
}
.presentation-public-badge.accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.public-empty, .public-loading, .public-error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-4);
}
.public-error { color: var(--danger); }
.public-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  color: var(--text-3);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  transition: color 0.2s, background 0.2s;
}
.public-back:hover { color: var(--text-1); background: var(--surface-2); }

/* ============================================================
   Сегодня / Учёба / Дом
   ============================================================ */
.today-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}
@media (min-width: 720px) {
  .today-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .today-grid { grid-template-columns: repeat(3, 1fr); }
}
.today-card h3 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  margin: 0 0 var(--s-3);
}
.today-card h3 i { width: 18px; height: 18px; color: var(--accent); }
.today-big {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.today-muted { color: var(--text-3); font-size: 0.88rem; margin: 0.25rem 0; }
.today-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.today-time {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  margin-right: 0.35rem;
}
.today-card-warn { border-color: rgba(251, 191, 36, 0.35); }
.today-skeleton {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}
.today-stats-details {
  margin-top: var(--s-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-1);
}
.today-stats-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-2);
  padding: var(--s-2) 0;
}

.quick-expense-card { margin-bottom: var(--s-4); }
.quick-expense-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-2);
  align-items: start;
}
.quick-expense-card code {
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.home-layout {
  display: grid;
  gap: var(--s-4);
}
@media (min-width: 900px) {
  .home-layout { grid-template-columns: 1fr 1fr; align-items: start; }
}
.shopping-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.shopping-list { display: flex; flex-direction: column; gap: 0.35rem; }
.shopping-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-2);
  align-items: center;
  padding: 0.55rem 0.7rem;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  cursor: pointer;
}
.shopping-item.done .shopping-text {
  text-decoration: line-through;
  color: var(--text-4);
}
.shopping-item input { width: 18px; height: 18px; accent-color: var(--accent); }
.home-empty { color: var(--text-4); font-size: 0.88rem; padding: var(--s-2) 0; }

.recurring-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
@media (min-width: 600px) {
  .recurring-form-grid { grid-template-columns: 2fr 1fr 1fr; }
}
.recurring-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: var(--s-3); }
.recurring-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  padding: 0.65rem 0.85rem;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.recurring-item.soon { border-color: rgba(251, 191, 36, 0.4); background: var(--warning-soft); }
.recurring-meta { display: block; font-size: 0.82rem; color: var(--text-3); margin-top: 0.15rem; }
.recurring-soon { font-size: 0.75rem; font-weight: 600; color: var(--warning); }

.study-top { margin-bottom: var(--s-4); }
.study-week-badge { margin: 0 0 0.35rem; font-size: 0.95rem; }
.study-period-hint { margin: 0; color: var(--text-3); font-size: 0.85rem; }
.study-period-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-subtle);
}
@media (min-width: 720px) {
  .study-period-form { grid-template-columns: repeat(3, 1fr); }
}
.study-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: var(--s-4);
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  border: 1px solid var(--border-subtle);
}
.study-tab {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-3);
  border-radius: var(--r-full);
  transition: background var(--t-fast), color var(--t-fast);
}
.study-tab.active { background: var(--accent); color: #fff; }
.study-tab:hover:not(.active) { color: var(--text-1); background: var(--surface-3); }

.study-cal-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.study-cal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
}
@media (min-width: 720px) {
  .study-cal-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
  .study-cal-grid { grid-template-columns: repeat(7, 1fr); }
}
.study-cal-day {
  padding: var(--s-3);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  min-height: 100px;
}
.study-cal-day.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.study-cal-day.out-period { opacity: 0.45; }
.study-cal-day-head {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
}
.study-cal-week-tag {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
}
.study-cal-empty { color: var(--text-4); font-size: 0.78rem; margin: 0; }
.study-slot { margin-bottom: 0.35rem; font-size: 0.78rem; line-height: 1.35; }
.study-slot-time { font-family: var(--font-mono); color: var(--accent); font-size: 0.72rem; }
.study-slot-subj { display: block; font-weight: 600; }
.study-slot-room { color: var(--text-4); font-size: 0.72rem; }

.study-editor-hint { color: var(--text-3); font-size: 0.88rem; margin: 0 0 var(--s-4); }
.study-day-block {
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
}
.study-day-block:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.study-day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-2);
}
.study-day-head h4 { margin: 0; font-size: 0.95rem; }
.study-slot-form {
  position: relative;
  padding: var(--s-3);
  margin-bottom: var(--s-2);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.study-slot-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  padding-right: 2.5rem;
}
.study-slot-wide { grid-column: 1 / -1; }
.study-slot-form .study-del-slot {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.study-exam-form { margin-bottom: var(--s-5); padding-bottom: var(--s-4); border-bottom: 1px solid var(--border-subtle); }
.study-exam-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
@media (min-width: 600px) {
  .study-exam-form-grid { grid-template-columns: 1fr 1fr; }
}
.study-exam-list { display: flex; flex-direction: column; gap: 0.4rem; }
.study-exam-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-3);
  align-items: start;
  padding: 0.75rem 0.85rem;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.study-exam-item.done { opacity: 0.55; }
.study-exam-item.overdue { border-color: rgba(251, 113, 133, 0.4); }
.study-exam-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.2rem; }
.study-exam-kind {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.study-exam-date { font-size: 0.82rem; color: var(--text-3); font-family: var(--font-mono); }
.study-exam-note { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--text-3); }

/* ============================================================
   Reduced motion — уважаем системные настройки
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .progress-bar::after { display: none; }
}

/* Print — скрываем UI */
@media print {
  .sidebar, .topbar, .mobile-format-bar, .toast-host, .sidebar-overlay { display: none !important; }
  .main-content { margin: 0 !important; padding: 1rem !important; }
  .glass-card { box-shadow: none; border: 1px solid #ccc; backdrop-filter: none; }
  body::before, body::after { display: none; }
}
