/* ===== ТЕМЫ ===== */
/* ===== ШРИФТ ===== */
/* The UI font is served locally by typography.css. */

/* ===== ТЕМЫ (акцентный цвет) ===== */
body {
  --bg: #0b0f17; --bg2: #121826; --card: #171f30; --border: #262f42;
  --accent: #3b82f6; --text: #e8ecf3; --muted: #8894a8;
  --green: #22c55e; --orange: #f59e0b; --red: #f43f5e; --purple: #8b5cf6;
  --sidebar-width: 264px; --bottom-nav-height: 64px;
  --radius: 10px;
  background: var(--bg); color: var(--text);
  transition: background .2s, color .2s;
  margin: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-feature-settings: 'tnum' 1, 'cv05' 1;
  -webkit-font-smoothing: antialiased;
}

/* Табличные (не пропорциональные) цифры — важно для сумм и статистики */
.widget-value, .finance-card-value, .transaction-amount, .balance-value,
.share-details, .transaction-date { font-variant-numeric: tabular-nums; }

/* ===== СВЕТЛЫЙ РЕЖИМ ===== */
/* Переключается отдельно от акцентной темы (см. setColorMode в app.js) —
   поверх любой из тем ниже можно включить светлый фон. */
body.mode-light {
  --bg: #f4f6fa; --bg2: #ffffff; --card: #ffffff; --border: #e2e6ee;
  --text: #131a29; --muted: #64748b;
}
body.mode-light .sidebar,
body.mode-light .bottom-nav,
body.mode-light .mobile-header { background: var(--bg2); }
body.mode-light .widget:hover,
body.mode-light .finance-card:hover,
body.mode-light .shopping-list-card:hover,
body.mode-light .transaction-item:hover { background: var(--card); }
body.mode-light .toast { box-shadow: 0 8px 24px rgba(20, 30, 60, .12); }
body.mode-light .widget,
body.mode-light .finance-card,
body.mode-light .list-item,
body.mode-light .shopping-list-card,
body.mode-light .transaction-item,
body.mode-light .modal,
body.mode-light .calendar-container,
body.mode-light .auth-form { box-shadow: 0 1px 2px rgba(20, 30, 60, .04); }

body.theme-forest { --bg: #0a120e; --bg2: #142118; --card: #1a2d22; --border: #2a4a35; --accent: #22c55e; --text: #e2f0e8; --muted: #8aaa9a; }
body.theme-sunset { --bg: #140f0a; --bg2: #231a12; --card: #342518; --border: #5a4025; --accent: #f59e0b; --text: #f0e8e0; --muted: #b09880; }
body.theme-purple { --bg: #0d0a14; --bg2: #1a1225; --card: #291a3a; --border: #402a55; --accent: #8b5cf6; --text: #e8e0f0; --muted: #a090b0; }
body.theme-rose { --bg: #140a0e; --bg2: #231218; --card: #341a25; --border: #552a3a; --accent: #ec4899; --text: #f0e0e8; --muted: #b090a0; }
body.theme-dark { --bg: #0a0810; --bg2: #121020; --card: #1a1830; --border: #2a2848; --accent: #7c3aed; --text: #e0e0f0; --muted: #9090b0; }

/* ===== STARRY NIGHT ===== */
body.theme-starry {
  --bg: #050a1a;
  --bg2: #0a1128;
  --card: #131b3a;
  --border: #1e2a5a;
  --accent: #fbbf24;
  --text: #e0e7ff;
  --muted: #8b9cd4;
  --green: #34d399;
  --orange: #fbbf24;
  --red: #f87171;
  --purple: #a78bfa;
  background: var(--bg);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

/* Звёздное небо - статичные звёзды */
body.theme-starry::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none; /* ← ВАЖНО: пропускает клики */
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 25% 45%, #fff, transparent),
    radial-gradient(2px 2px at 40% 15%, #fbbf24, transparent),
    radial-gradient(1px 1px at 55% 70%, #fff, transparent),
    radial-gradient(1px 1px at 70% 30%, #a78bfa, transparent),
    radial-gradient(2px 2px at 85% 85%, #fff, transparent),
    radial-gradient(1px 1px at 15% 80%, #fff, transparent),
    radial-gradient(1px 1px at 35% 60%, #60a5fa, transparent),
    radial-gradient(2px 2px at 90% 10%, #fff, transparent),
    radial-gradient(1px 1px at 60% 40%, #fff, transparent),
    radial-gradient(1px 1px at 5% 55%, #fbbf24, transparent),
    radial-gradient(1px 1px at 45% 90%, #fff, transparent),
    radial-gradient(2px 2px at 75% 55%, #a78bfa, transparent),
    radial-gradient(1px 1px at 20% 35%, #fff, transparent),
    radial-gradient(1px 1px at 95% 65%, #fff, transparent),
    radial-gradient(1px 1px at 50% 25%, #60a5fa, transparent),
    radial-gradient(2px 2px at 30% 95%, #fff, transparent),
    radial-gradient(1px 1px at 80% 45%, #fff, transparent);
  background-size: 100% 100%;
  animation: twinkle 4s ease-in-out infinite;
}

/* Дополнительные яркие звёзды */
body.theme-starry::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none; /* ← ВАЖНО: пропускает клики */
  z-index: 0;
  background-image:
    radial-gradient(3px 3px at 12% 28%, rgba(251, 191, 36, 0.8), transparent),
    radial-gradient(3px 3px at 88% 72%, rgba(167, 139, 250, 0.8), transparent),
    radial-gradient(3px 3px at 48% 52%, rgba(96, 165, 250, 0.8), transparent),
    radial-gradient(2px 2px at 72% 18%, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(2px 2px at 22% 82%, rgba(255, 255, 255, 0.9), transparent);
  background-size: 100% 100%;
  animation: twinkle 6s ease-in-out infinite reverse;
}

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Контент поверх звёзд (но БЕЗ изменения position у AI-бота!) */
body.theme-starry .auth-page,
body.theme-starry .app-page,
body.theme-starry .modal-overlay {
  position: relative;
  z-index: 1;
}

/* ⚠️ ВАЖНО: НЕ трогаем #aiAssistantContainer!
   Он должен оставаться position: fixed с z-index: 999
   как в оригинальном CSS */

/* Полупрозрачные карточки */
body.theme-starry .widget,
body.theme-starry .finance-card,
body.theme-starry .settings-section,
body.theme-starry .list-item,
body.theme-starry .shopping-list-card,
body.theme-starry .transaction-item,
body.theme-starry .modal,
body.theme-starry .calendar-container,
body.theme-starry .sidebar,
body.theme-starry .bottom-nav,
body.theme-starry .auth-form {
  background: rgba(10, 17, 40, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Золотистое свечение */
body.theme-starry .widget:hover,
body.theme-starry .finance-card:hover,
body.theme-starry .shopping-list-card:hover,
body.theme-starry .transaction-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

body.theme-starry .sidebar-nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

body.theme-starry .bottom-nav-item.active {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* Градиентный заголовок */
body.theme-starry .sidebar-header h1,
body.theme-starry .mobile-header h1,
body.theme-starry header h1 {
  background: linear-gradient(90deg, #fbbf24, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Точка для кнопки темы */
body.theme-starry .theme-btn .theme-dot.starry {
  background: radial-gradient(circle at 30% 30%, #fbbf24, #050a1a);
  box-shadow: 0 0 4px #fbbf24;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 100;
  transition: transform .3s ease, background .3s, border-color .3s;
}
.sidebar-header { padding: 22px 20px; border-bottom: 1px solid var(--border); }
.sidebar-header h1 {
  font-size: 19px; font-weight: 800; letter-spacing: -.02em;
  color: var(--text); display: flex; align-items: center; gap: 8px;
}
.sidebar-header h1::before {
  content: ''; display: inline-block; width: 8px; height: 8px;
  border-radius: 2px; background: var(--accent); flex-shrink: 0;
}
.sidebar-user {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-size: 14px; color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px; border-radius: 8px;
  color: var(--muted); cursor: pointer;
  font-size: 14.5px; border: none;
  transition: background .15s, color .15s; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.sidebar-nav-item:hover { background: var(--card); color: var(--text); }
.sidebar-nav-item.active {
  color: var(--accent); background: var(--card); font-weight: 600;
}
.sidebar-nav-item .nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sidebar-nav-item .nav-icon .icon { width: 18px; height: 18px; }
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}
.sidebar-footer button {
  flex: 1; padding: 8px 12px; border-radius: 6px; border: none;
  cursor: pointer; font-size: 13px; font-weight: 500; transition: opacity .2s;
}
.sidebar-footer button:hover { opacity: .85; }
.sync-btn { background: var(--accent); color: #fff; }
.logout-btn { background: var(--red); color: #fff; }

/* ===== ПЕРЕКЛЮЧАТЕЛЬ СВЕТЛАЯ/ТЁМНАЯ ===== */
.mode-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; flex: 0 0 36px; padding: 8px 0 !important;
  background: var(--bg2) !important; border: 1px solid var(--border) !important;
  color: var(--text) !important; font-size: 15px;
}
.mode-toggle:hover { opacity: 1 !important; border-color: var(--accent) !important; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width); min-height: 100vh;
  padding: 28px 32px; transition: margin-left .3s;
  max-width: 1400px;
}

/* ===== BOTTOM NAV (MOBILE) ===== */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height); background: var(--bg2);
  border-top: 1px solid var(--border); z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-items {
  display: flex; height: 100%; justify-content: space-around; align-items: center;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 6px; color: var(--muted);
  cursor: pointer; background: none; border: none; font-family: inherit;
  transition: color .2s; height: 100%;
}
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item .nav-icon { font-size: 22px; }
.bottom-nav-item .nav-label { font-size: 10px; font-weight: 500; }

/* ===== MOBILE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.5); }
  .main-content { margin-left: 0; padding: 16px 16px calc(var(--bottom-nav-height) + 16px) 16px; }
  .bottom-nav { display: block; }
  .mobile-header { display: flex !important; }
}
.mobile-header {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid var(--border);
  margin: -16px -16px 16px -16px;
}
.mobile-header h1 {
  font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: var(--text);
  display: flex; align-items: center; gap: 7px;
}
.mobile-header h1::before {
  content: ''; display: inline-block; width: 7px; height: 7px;
  border-radius: 2px; background: var(--accent); flex-shrink: 0;
}
.hamburger-btn {
  background: none; border: none; color: var(--text);
  font-size: 24px; cursor: pointer; padding: 4px 8px;
}
.sidebar-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
.page-title {
  font-size: 24px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 12px;
}

/* ===== DASHBOARD WIDGETS ===== */
.dashboard-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.widget {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  transition: border-color .15s, background .2s;
}
.widget:hover { border-color: var(--accent); }
.widget-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.widget-title {
  font-size: 12px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.widget-icon { font-size: 20px; opacity: .85; }
.widget-value { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; }
.widget-subtitle { font-size: 12.5px; color: var(--muted); }
.widget-value.positive { color: var(--green); }
.widget-value.negative { color: var(--red); }
.widget-wide { grid-column: 1 / -1; }
.widget-delta { font-size: 12px; font-weight: 600; margin-top: 6px; }
.widget-delta.delta-good { color: var(--green); }
.widget-delta.delta-bad { color: var(--red); }

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-action-btn {
  flex: 1; min-width: 120px; padding: 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  cursor: pointer; font-size: 14px; font-weight: 500; transition: all .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.quick-action-btn:hover { border-color: var(--accent); background: var(--card); }
.quick-action-btn.income { border-color: var(--green); color: var(--green); }
.quick-action-btn.expense { border-color: var(--red); color: var(--red); }

.widget-task-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 240px; overflow-y: auto;
}
.widget-task-item {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  background: var(--bg2); border-radius: 6px; font-size: 14px;
  cursor: pointer; transition: background .2s;
}
.widget-task-item:hover { background: var(--bg); }

/* ===== FINANCE ===== */
.finance-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.finance-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.finance-card-label {
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.finance-card-value { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.finance-card-value.income { color: var(--green); }
.finance-card-value.expense { color: var(--red); }
.finance-card-value.balance { color: var(--accent); }

.transaction-list { display: flex; flex-direction: column; gap: 8px; }

/* ===== БАР-ЧАРТ ПО КАТЕГОРИЯМ ===== */
.category-bars { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.category-bar-row { display: flex; flex-direction: column; gap: 5px; }
.category-bar-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--text);
}
.category-bar-total { color: var(--muted); font-variant-numeric: tabular-nums; }
.category-bar-track {
  height: 7px; border-radius: 4px; background: var(--bg2); overflow: hidden;
}
.category-bar-fill {
  height: 100%; border-radius: 4px; transition: width .4s ease;
}
.transaction-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: border-color .2s;
}
.transaction-item:hover { border-color: var(--accent); }
.transaction-icon {
  font-size: 24px; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); border-radius: 50%; flex-shrink: 0;
}
.transaction-info { flex: 1; min-width: 0; }
.transaction-category { font-weight: 500; font-size: 14px; }
.transaction-note {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.transaction-amount { font-weight: 600; font-size: 16px; white-space: nowrap; }
.transaction-amount.income { color: var(--green); }
.transaction-amount.expense { color: var(--red); }
.transaction-amount.transfer { color: var(--accent); }
.transaction-date { font-size: 11px; color: var(--muted); }

/* ===== TOASTS (уведомления вместо alert) ===== */
#toastContainer {
  position: fixed; top: 20px; right: 20px; z-index: 3000;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none; align-items: flex-end;
}
.toast {
  pointer-events: auto; cursor: pointer;
  background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  color: var(--text); padding: 12px 20px; border-radius: 10px;
  font-size: 14px; max-width: 340px; white-space: pre-wrap;
  user-select: text; -webkit-user-select: text;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  animation: toastIn .25s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--accent); }
.toast.hide { animation: toastOut .25s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px) scale(.95); }
}
@media (max-width: 900px) {
  #toastContainer { top: 12px; left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: none; }
}

/* ===== TOAST С КНОПКОЙ ОТМЕНЫ ===== */
.toast.undo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.toast-undo-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  flex-shrink: 0; font-family: inherit;
}
.toast-undo-btn:active { opacity: .8; }

/* ===== АДМИН-ДАШБОРД ===== */
.admin-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.admin-stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.admin-stat b { font-size: 18px; }
.admin-stat span { font-size: 12px; color: var(--muted); }

/* ===== AUTH ===== */
.auth-page { display: none; }
.auth-page.active { display: flex; }
.auth-container {
  width: 100%; max-width: 420px; margin: auto;
  display: flex; flex-direction: column; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-form {
  background: var(--card); padding: 40px; border-radius: 12px;
  border: 1px solid var(--border); transition: background .3s, border-color .3s;
}
.auth-form h2 { margin-bottom: 8px; font-size: 22px; text-align: center; }
.auth-form .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 12px 16px; border-radius: 6px; font-size: 14px;
  transition: border-color .2s, background .3s, color .3s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); }
.form-group .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.auth-button {
  width: 100%; background: var(--accent); color: #fff; border: none;
  padding: 12px; border-radius: 6px; font-size: 15px; font-weight: 500;
  cursor: pointer; transition: opacity .2s, background .3s;
}
.auth-button:hover { opacity: .9; }
.auth-toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-toggle a { color: var(--accent); cursor: pointer; text-decoration: underline; }
.error-msg {
  background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .3);
  color: #fca5a5; padding: 12px; border-radius: 6px; margin-bottom: 16px;
  font-size: 13px; display: none;
}
.error-msg.show { display: block; }
.success-msg {
  background: rgba(16, 185, 129, .1); border: 1px solid rgba(16, 185, 129, .3);
  color: #86efac; padding: 12px; border-radius: 6px; margin-bottom: 16px;
  font-size: 13px; display: none;
}
.success-msg.show { display: block; }
.app-page { display: none; }
.app-page.active { display: block; }

/* ===== LISTS & ITEMS ===== */
.input-section {
  display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
  background: var(--bg2); padding: 16px; border-radius: 12px;
  border: 1px solid var(--border);
}
.input-section input {
  flex: 1; background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 12px 16px; border-radius: 8px;
  font-size: 15px; min-width: 150px; outline: none;
}
.input-section input:focus { outline: none; border-color: var(--accent); }
.add-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 12px 24px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 15px; transition: opacity .2s;
}
.add-btn:hover { opacity: .9; }
.list { display: grid; gap: 12px; }
.list-item {
  background: var(--card); border: 1px solid var(--border);
  padding: 14px 16px; border-radius: 8px;
  display: flex; align-items: center; gap: 12px;
  transition: all .2s; flex-wrap: wrap;
}
.list-item:hover { border-color: #4a6a8a; }
.list-item.completed { opacity: 0.7; }
.list-item.completed .item-text { text-decoration: line-through; }
.list-item.pinned { border-left: 3px solid var(--orange); }
.list-item.shared { border-left: 3px solid var(--purple); }
.shared-badge {
  background: var(--purple); color: #fff; padding: 2px 8px;
  border-radius: 4px; font-size: 10px; margin-left: 8px;
}
.checkbox { width: 20px; height: 20px; cursor: pointer; accent-color: var(--green); flex-shrink: 0; }
.item-text { flex: 1; word-break: break-word; min-width: 120px; }
.delete-btn {
  background: var(--red); color: #fff; border: none;
  padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.edit-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 14px;
}
.pin-btn {
  background: var(--orange); color: #fff; border: none;
  padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 14px;
}
.pin-btn.unpin { background: var(--muted); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.task-meta {
  display: flex; gap: 8px; align-items: center; font-size: 12px;
  color: var(--muted); margin-top: 4px; flex-wrap: wrap;
}
.priority-badge { padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.priority-high { background: rgba(239, 68, 68, .2); color: #fca5a5; }
.priority-normal { background: rgba(59, 130, 246, .2); color: #93c5fd; }
.priority-low { background: rgba(16, 185, 129, .2); color: #86efac; }
.due-date { padding: 2px 8px; border-radius: 4px; background: rgba(94, 109, 238, .2); color: #c4b5fd; }
.reminder-badge { padding: 2px 8px; border-radius: 4px; background: rgba(245, 158, 11, .2); color: #fcd34d; font-size: 11px; }
.reminder-sent { color: var(--green); font-size: 11px; }
.category-badge { padding: 2px 8px; border-radius: 4px; background: rgba(139, 92, 246, .2); color: #c4b5fd; font-size: 11px; }
.recurring-badge { padding: 2px 8px; border-radius: 4px; background: rgba(16, 185, 129, .2); color: #86efac; font-size: 11px; }
.pinned-badge { color: var(--orange); font-size: 11px; }

/* ===== SETTINGS ===== */
.settings-section {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; margin-bottom: 24px;
}
.settings-section h3 { margin-bottom: 12px; font-size: 16px; }
.settings-section p { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.settings-section input {
  width: 100%; max-width: 400px; background: var(--bg);
  border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 12px;
}
.settings-section input:focus { outline: none; border-color: var(--accent); }
.status { display: inline-block; padding: 4px 12px; border-radius: 4px; font-size: 13px; margin-top: 8px; }
.status-success { background: rgba(16, 185, 129, .2); color: #86efac; }
.status-error { background: rgba(239, 68, 68, .2); color: #fca5a5; }

.settings-section select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 12px 16px; border-radius: 8px;
  font-size: 15px; outline: none;
}
.settings-section select:focus { outline: none; border-color: var(--accent); }
.settings-section .form-group { margin-bottom: 16px; }
.settings-section .form-group label {
  display: block; font-size: 14px; font-weight: 500;
  color: var(--muted); margin-bottom: 6px;
}
.share-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg); border-radius: 8px;
  margin-bottom: 8px; border: 1px solid var(--border);
}
.share-item:hover { border-color: #4a6a8a; }
.share-item .share-info { flex: 1; }
.share-item .share-info .share-name { font-weight: 600; color: var(--text); font-size: 15px; }
.share-item .share-info .share-details { font-size: 13px; color: var(--muted); margin-top: 2px; }
#shareStatus { margin-top: 12px; padding: 12px; border-radius: 8px; font-size: 14px; }
#shareStatus.success { background: rgba(16, 185, 129, .1); border: 1px solid rgba(16, 185, 129, .3); color: #86efac; }
#shareStatus.error { background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5; }

/* ===== FILTERS ===== */
.filters-bar {
  display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
  background: var(--bg2); padding: 16px; border-radius: 12px;
  border: 1px solid var(--border); align-items: center;
}
.filters-bar input, .filters-bar select {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 6px;
  font-size: 14px; flex: 1; min-width: 130px; outline: none;
}
.filters-bar .filter-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 20px; border-radius: 6px; cursor: pointer;
  font-weight: 500; white-space: nowrap;
}
.filters-bar .clear-btn { background: var(--red); }
.add-task-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 14px 28px; border-radius: 12px; font-size: 16px;
  font-weight: 600; cursor: pointer; width: 100%; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}

/* ===== CALENDAR ===== */
.calendar-container {
  background: var(--bg2); border-radius: 16px; padding: 24px;
  border: 1px solid var(--border);
}
.calendar-nav {
  display: flex; justify-content: center; align-items: center;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.calendar-nav button {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 8px 16px; border-radius: 8px;
  cursor: pointer; font-size: 16px;
}
.calendar-nav button:hover { background: var(--accent); border-color: var(--accent); }
.calendar-nav .today-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.calendar-nav h2 { font-size: 20px; min-width: 150px; text-align: center; }
.calendar-grid { background: var(--bg); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.calendar-weekdays div { padding: 12px; text-align: center; font-weight: 600; font-size: 14px; color: var(--muted); }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-day {
  padding: 12px 8px; min-height: 80px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  cursor: pointer; transition: all .2s; position: relative;
}
.calendar-day:nth-child(7n) { border-right: none; }
.calendar-day:hover { background: var(--bg2); }
.calendar-day.other-month { opacity: .3; }
.calendar-day.today { background: rgba(59, 130, 246, .1); }
.calendar-day.selected { border: 2px solid var(--accent); }
.calendar-day .day-number { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.calendar-day .day-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent); margin: 1px;
}
.calendar-day .day-dot.many { background: var(--orange); }
.calendar-tasks { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.calendar-tasks h3 { margin-bottom: 16px; font-size: 18px; color: var(--accent); }
.calendar-tasks .list-item { background: var(--bg); }

/* ===== SHOPPING LISTS ===== */
.shopping-lists-container { display: grid; gap: 16px; margin-top: 16px; }
.shopping-list-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; transition: border-color .2s;
}
.shopping-list-card:hover { border-color: var(--accent); }
.shopping-list-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.shopping-list-header h4 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.shopping-list-header .list-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.shopping-list-header .list-actions button {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 4px 12px; border-radius: 6px;
  cursor: pointer; font-size: 12px;
}
.shopping-list-header .list-actions button:hover { border-color: var(--accent); }
.shopping-list-header .list-actions .delete-list-btn { background: var(--red); color: #fff; border: none; }
.shopping-list-items { display: grid; gap: 6px; }
.shopping-list-items .list-item { padding: 8px 12px; background: var(--bg); }
.shopping-list-items .list-item .item-text { font-size: 14px; }
.shopping-list-badge {
  font-size: 11px; padding: 2px 10px; border-radius: 12px;
  background: rgba(139, 92, 246, .2); color: #c4b5fd;
}
.shopping-list-badge.shared { background: rgba(59, 130, 246, .2); color: #93c5fd; }
.create-list-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 12px 24px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 15px; width: 100%; margin-bottom: 16px;
}

/* ===== THEMES ===== */
.theme-selector { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.theme-btn {
  background: var(--bg); border: 2px solid var(--border); color: var(--text);
  padding: 10px 20px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  font-family: inherit;
}
.theme-btn:hover { border-color: var(--accent); transform: scale(1.02); }
.theme-btn.active { border-color: var(--accent); box-shadow: 0 0 20px rgba(59, 130, 246, .2); }
.theme-btn .theme-dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; }
.theme-btn .theme-dot.ocean { background: #3b82f6; }
.theme-btn .theme-dot.forest { background: #22c55e; }
.theme-btn .theme-dot.sunset { background: #f59e0b; }
.theme-btn .theme-dot.purple { background: #8b5cf6; }
.theme-btn .theme-dot.rose { background: #ec4899; }
.theme-btn .theme-dot.dark { background: #7c3aed; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.7); z-index: 1000;
  justify-content: center; align-items: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; max-width: 550px;
  width: 100%; max-height: 90vh; overflow-y: auto; position: relative;
}
.modal h2 { margin-bottom: 20px; font-size: 20px; padding-right: 30px; }
.modal-close {
  position: absolute; top: 12px; right: 16px; font-size: 24px;
  cursor: pointer; background: none; border: none; color: var(--muted);
  padding: 4px 8px;
}
.modal .form-group { margin-bottom: 14px; }
.modal .form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.modal .form-group input, .modal .form-group select {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 6px; font-size: 14px;
  box-sizing: border-box;
}
.modal .form-group input:focus, .modal .form-group select:focus { outline: none; border-color: var(--accent); }
.modal .form-submit {
  width: 100%; background: var(--accent); color: #fff; border: none;
  padding: 12px; border-radius: 6px; font-size: 15px; font-weight: 500;
  cursor: pointer; margin-top: 8px;
}
.modal .checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; }
.modal .checkbox-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; color: var(--text); }
.modal .checkbox-group input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.modal .section-title {
  font-size: 14px; font-weight: 600; color: var(--accent);
  margin: 16px 0 8px 0; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.modal .section-title:first-of-type { margin-top: 0; }
.modal textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 14px 16px; border-radius: 8px;
  font-size: 15px; font-family: inherit; resize: vertical;
  min-height: 100px; line-height: 1.6; outline: none; box-sizing: border-box;
}
.modal textarea:focus { outline: none; border-color: var(--accent); }

/* ===== AI ASSISTANT ===== */
#aiAssistantContainer { position: fixed; bottom: 80px; right: 20px; z-index: 999; }
#aiToggleBtn {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff; border: none; font-size: 28px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(59, 130, 246, .4);
}
#aiToggleBtn:hover { transform: scale(1.05); }
#aiChatWindow {
  display: none; position: absolute; bottom: 70px; right: 0;
  width: 380px; max-width: calc(100vw - 40px); max-height: 500px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  overflow: hidden; flex-direction: column;
}
#aiChatWindow.open { display: flex; }
#aiMessages {
  padding: 16px; overflow-y: auto; max-height: 350px; min-height: 200px;
  display: flex; flex-direction: column; gap: 8px;
}
#aiMessages .ai-message {
  padding: 10px 14px; border-radius: 12px; max-width: 85%;
  font-size: 14px; white-space: pre-wrap; word-wrap: break-word;
  animation: slideIn .2s ease;
}
#aiMessages .ai-message.user { background: var(--accent); color: #fff; align-self: flex-end; }
#aiMessages .ai-message.assistant { background: var(--card); color: var(--text); align-self: flex-start; }
#aiMessages .ai-message.error { background: rgba(239, 68, 68, .2); color: #fca5a5; align-self: flex-start; }
#aiMessages .ai-message .typing-dots { display: inline-block; }
#aiMessages .ai-message .typing-dots span {
  display: inline-block; animation: pulse 1.4s infinite both;
  font-size: 18px; margin: 0 2px;
}
#aiMessages .ai-message .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
#aiMessages .ai-message .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ===== MOBILE ADAPTATION ===== */
@media (max-width: 900px) {
  .filters-bar input, .filters-bar select { min-width: 100px; font-size: 13px; padding: 8px 12px; }
  .calendar-day { min-height: 60px; padding: 8px 4px; }
  .calendar-day .day-number { font-size: 12px; }
  .calendar-nav h2 { font-size: 16px; min-width: 120px; }
  #aiAssistantContainer { bottom: calc(var(--bottom-nav-height) + 16px); }
  #aiChatWindow { width: calc(100vw - 20px) !important; max-height: 70vh !important; }
  #aiToggleBtn { width: 50px !important; height: 50px !important; font-size: 24px !important; }
}
@media (max-width: 600px) {
  .page-title { font-size: 20px; }
  .widget-value { font-size: 22px; }
  .finance-card-value { font-size: 20px; }
  .modal { padding: 20px; }
  .input-section input { font-size: 14px; padding: 8px 10px; }
  .input-section .add-btn { font-size: 14px; padding: 8px 16px; width: 100%; }
  .shopping-list-header { flex-direction: column; align-items: stretch; }
}
/* ===== АНИМАЦИЯ ПЕРЕКЛЮЧЕНИЯ ВКЛАДОК ===== */
.page.active {
  animation: pageIn .3s cubic-bezier(.22, .8, .36, 1);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Лёгкий эффект нажатия на пункты меню */
.sidebar-nav-item:active { transform: scale(.96); }
.sidebar-nav-item { transition: transform .15s ease; }

/* Уважение к настройкам устройства (без анимаций, если включено «уменьшить движение») */
@media (prefers-reduced-motion: reduce) {
  .page.active { animation: none; }
}
.task-comment {
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--bg-tertiary, rgba(0,0,0,0.05));
  border-left: 3px solid var(--accent-color, #3b82f6);
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--text-secondary, #666);
  white-space: pre-wrap;
  word-break: break-word;
}
/* ===== УЛУЧШЕННАЯ ЧИТАЕМОСТЬ В СВЕТЛОЙ ТЕМЕ ===== */

body.mode-light {
  --text: #111827;
  --muted: #475569;
}

/* Основной текст задачи */
body.mode-light .item-text {
  color: #1e293b;
  font-weight: 500;
}

/* Метаданные задачи */
body.mode-light .task-meta {
  color: #475569;
}

/* Категория */
body.mode-light .category-badge {
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
  font-weight: 600;
}

/* Обычный приоритет */
body.mode-light .priority-normal {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  font-weight: 600;
}

/* Высокий приоритет */
body.mode-light .priority-high {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  font-weight: 600;
}

/* Низкий приоритет */
body.mode-light .priority-low {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
  font-weight: 600;
}

/* Дата выполнения */
body.mode-light .due-date {
  background: rgba(79, 70, 229, 0.12);
  color: #4338ca;
  font-weight: 600;
}

/* Напоминание */
body.mode-light .reminder-badge {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  font-weight: 600;
}

/* Напоминание отправлено */
body.mode-light .reminder-sent {
  color: #15803d;
  font-weight: 600;
}

/* Повторяющаяся задача */
body.mode-light .recurring-badge {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
  font-weight: 600;
}

/* Закреплённая задача */
body.mode-light .pinned-badge {
  color: #b45309;
  font-weight: 600;
}

/* Комментарий к задаче */
body.mode-light .task-comment {
  background: #f1f5f9;
  color: #334155;
  border-left-color: var(--accent);
}
/* =========================================
   СВЕТЛАЯ ТЕМА — УЛУЧШЕННАЯ ЧИТАЕМОСТЬ
========================================= */

body.mode-light {
  --text: #111827;
  --muted: #475569;
}

/* Основной текст */
body.mode-light .settings-section,
body.mode-light .admin-stat,
body.mode-light .list-item {
  color: #1e293b;
}

/* Описание в админ-панели */
body.mode-light .settings-section p {
  color: #475569;
}

/* Подключён Telegram / статусы */
body.mode-light .status-success {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  font-weight: 600;
}

/* Ошибки */
body.mode-light .status-error {
  background: rgba(220, 38, 38, 0.10);
  color: #b91c1c;
  font-weight: 600;
}

/* Успешный статус подключения Telegram */
body.mode-light #telegramStatus,
body.mode-light .telegram-status {
  color: #15803d;
}

/* Общие success-сообщения */
body.mode-light .success-msg {
  background: rgba(22, 163, 74, 0.10);
  border-color: rgba(22, 163, 74, 0.25);
  color: #15803d;
}

/* Основной текст задачи */
body.mode-light .item-text {
  color: #1e293b;
  font-weight: 500;
}

/* Выполненные задачи — не слишком бледные */
body.mode-light .list-item.completed {
  opacity: 0.7;
}
