/* ══════════════════════════════════════════════════════════════════════════════
   View Transitions
   ══════════════════════════════════════════════════════════════════════════════ */

@view-transition { navigation: auto; }

::view-transition-old(root) {
  animation: vt-out 0.22s cubic-bezier(0.4, 0, 1, 1) both;
}
::view-transition-new(root) {
  animation: vt-in 0.28s cubic-bezier(0, 0, 0.2, 1) both;
}

@keyframes vt-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.99); }
}
@keyframes vt-in {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Sidebar keeps its position during transitions */
::view-transition-old(sidebar),
::view-transition-new(sidebar) {
  animation: none;
}

.sidebar { view-transition-name: sidebar; }

/* Shared-element transition: set dynamically via JS on click, not statically */
::view-transition-old(recipe-active) {
  animation: vt-out 0.22s cubic-bezier(0.4, 0, 1, 1) both;
}
::view-transition-new(recipe-active) {
  animation: vt-in 0.28s cubic-bezier(0, 0, 0.2, 1) both;
}

/* ══════════════════════════════════════════════════════════════════════════════
   CSS Custom Properties
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* Spacing */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-sm: 6px;  --radius: 10px;  --radius-lg: 16px;  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --t-fast: 120ms ease; --t: 200ms ease; --t-slow: 350ms ease;

  /* Sidebar */
  --sidebar-w: 220px;
  --sidebar-collapsed-w: 64px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Z-layers */
  --z-sidebar: 100; --z-header: 90; --z-modal: 200; --z-toast: 300;
}

/* Light theme */
:root, [data-theme="light"] {
  --bg: #f8f9fb;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --bg-input: #f1f3f5;
  --bg-hover: #f3f4f6;
  --bg-sidebar: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --text-on-accent: #ffffff;

  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --accent-border: #c7d2fe;

  --success: #10b981; --success-light: #d1fae5;
  --warning: #f59e0b; --warning-light: #fef3c7;
  --danger:  #ef4444; --danger-light:  #fee2e2;
  --info:    #3b82f6; --info-light:    #dbeafe;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.16);
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-elevated: #1f2235;
  --bg-input: #252840;
  --bg-hover: #252840;
  --bg-sidebar: #13151f;
  --border: #2d3148;
  --border-strong: #3d4163;

  --text: #f1f2f6;
  --text-muted: #8b8fa8;
  --text-faint: #5c6080;
  --text-on-accent: #ffffff;

  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-light: #1e2046;
  --accent-border: #3d4163;

  --success: #34d399; --success-light: #064e3b;
  --warning: #fbbf24; --warning-light: #451a03;
  --danger:  #f87171; --danger-light:  #450a0a;
  --info:    #60a5fa; --info-light:    #1e3a5f;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.6);
}

/* ══════════════════════════════════════════════════════════════════════════════
   Reset & Base
   ══════════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--t), color var(--t);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ══════════════════════════════════════════════════════════════════════════════
   Layout
   ══════════════════════════════════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--t-slow), background var(--t);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
  min-height: 64px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: var(--space-4) var(--space-2) var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

.user-info {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left var(--t-slow);
}

.top-bar {
  position: sticky; top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  z-index: var(--z-header);
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  transition: background var(--t), border-color var(--t);
}

.top-bar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-content {
  flex: 1;
  padding: var(--space-6);
  max-width: 1200px;
  width: 100%;
}

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  padding: var(--space-2) var(--space-4) calc(var(--space-2) + env(safe-area-inset-bottom));
  z-index: var(--z-sidebar);
  gap: var(--space-1);
  justify-content: space-around;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-faint);
  font-size: 0.65rem;
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius);
  transition: color var(--t-fast), background var(--t-fast);
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
}

.bottom-nav-item .bnav-icon { font-size: 1.3rem; }
.bottom-nav-item.active { color: var(--accent); }

/* ══════════════════════════════════════════════════════════════════════════════
   Buttons
   ══════════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); color: white; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.35); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #dc2626; color: white; }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #059669; color: white; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: 1rem; }
.btn-icon { padding: var(--space-2); width: 36px; height: 36px; }

/* ══════════════════════════════════════════════════════════════════════════════
   Cards
   ══════════════════════════════════════════════════════════════════════════════ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t), border-color var(--t), background var(--t);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.card-body { padding: var(--space-5); }
.card-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════════════════════════
   Forms
   ══════════════════════════════════════════════════════════════════════════════ */

.form-group { display: flex; flex-direction: column; gap: var(--space-1); }

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  padding: 10px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-control::placeholder { color: var(--text-faint); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: 0.78rem; color: var(--text-faint); }

.form-grid { display: grid; gap: var(--space-4); }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ══════════════════════════════════════════════════════════════════════════════
   Toast / Flash
   ══════════════════════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed; top: var(--space-5); right: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: toast-in var(--t-slow) ease both;
}

.toast.hiding { animation: toast-out var(--t) ease both; }

@keyframes toast-in  { from { opacity:0; transform:translateX(24px) scale(.95); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; transform:none; } to { opacity:0; transform:translateX(24px); } }

.toast-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; font-size: 0.875rem; color: var(--text); }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 2px; line-height: 1; font-size: 1rem; }

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
.toast.warning { border-left: 3px solid var(--warning); }

/* ══════════════════════════════════════════════════════════════════════════════
   Modal
   ══════════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--t);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(.97);
  transition: transform var(--t);
}

.modal-overlay.open .modal {
  transform: none;
}

.modal-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.modal-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); display: flex; gap: var(--space-2); justify-content: flex-end; }

/* ══════════════════════════════════════════════════════════════════════════════
   Badge
   ══════════════════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-accent  { background: var(--accent-light);  color: var(--accent); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-muted   { background: var(--bg-hover);      color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════════════════════
   Stat cards
   ══════════════════════════════════════════════════════════════════════════════ */

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
  transition: box-shadow var(--t), transform var(--t);
}

.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-sub   { font-size: 0.8rem; color: var(--text-faint); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: var(--space-1);
}

/* ══════════════════════════════════════════════════════════════════════════════
   Progress bar
   ══════════════════════════════════════════════════════════════════════════════ */

.progress {
  height: 8px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width var(--t-slow);
}

.progress-bar.danger  { background: var(--danger); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.success { background: var(--success); }

/* ══════════════════════════════════════════════════════════════════════════════
   Auth pages
   ══════════════════════════════════════════════════════════════════════════════ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--space-4);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: var(--space-8);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-logo .logo-big {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto var(--space-3);
}

.auth-title { font-size: 1.5rem; font-weight: 800; text-align: center; margin-bottom: var(--space-1); }
.auth-subtitle { font-size: 0.875rem; color: var(--text-muted); text-align: center; }

/* ══════════════════════════════════════════════════════════════════════════════
   Recipes
   ══════════════════════════════════════════════════════════════════════════════ */

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}

.recipe-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--t);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.recipe-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--accent-border);
}

.recipe-card-img {
  height: 200px;
  background: var(--bg-hover);
  overflow: hidden;
  position: relative;
}

.recipe-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}

.recipe-card:hover .recipe-card-img img { transform: scale(1.04); }

.recipe-card-no-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3.5rem;
  color: var(--text-faint);
  background: linear-gradient(135deg, var(--accent-light), var(--bg-hover));
}

.recipe-card-fav {
  position: absolute; top: var(--space-2); right: var(--space-2);
  width: 32px; height: 32px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
}

.recipe-card-fav:hover { transform: scale(1.15); }

.recipe-card-body { padding: var(--space-4); flex: 1; display: flex; flex-direction: column; gap: var(--space-2); }
.recipe-card-title { font-size: 1rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.recipe-card-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; flex: 1;
                    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.recipe-card-meta {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: 0.78rem; color: var(--text-faint);
}

.recipe-meta-item { display: flex; align-items: center; gap: 4px; }

/* Recipe list view */
.recipe-list { display: flex; flex-direction: column; gap: var(--space-3); }

.recipe-list-item {
  display: flex; align-items: center; gap: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  transition: all var(--t-fast);
  text-decoration: none;
  color: inherit;
}

.recipe-list-item:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
  color: inherit;
}

.recipe-list-thumb {
  width: 64px; height: 64px;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
}

.recipe-list-thumb img { width: 100%; height: 100%; object-fit: cover; }

.recipe-list-info { flex: 1; min-width: 0; }
.recipe-list-title { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.recipe-list-meta { font-size: 0.78rem; color: var(--text-faint); margin-top: 2px; }

/* Recipe detail */
.recipe-hero {
  border-radius: var(--radius-xl);
  overflow: hidden;
  height: 340px;
  background: var(--bg-hover);
  position: relative;
  margin-bottom: var(--space-6);
}

.recipe-hero img { width: 100%; height: 100%; object-fit: cover; }

.recipe-hero-no-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 6rem;
  background: linear-gradient(135deg, var(--accent-light), var(--bg-hover));
}

.recipe-meta-bar {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}

.recipe-meta-block { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; min-width: 70px; }
.recipe-meta-icon { font-size: 1.3rem; }
.recipe-meta-value { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.recipe-meta-label { font-size: 0.7rem; color: var(--text-faint); }

.ingredient-list { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.ingredient-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-hover);
  font-size: 0.9rem;
}
.ingredient-item::before { content: '•'; color: var(--accent); font-weight: 700; }

.step-list { display: flex; flex-direction: column; gap: var(--space-4); }
.step-item { display: flex; gap: var(--space-4); }
.step-num {
  width: 32px; height: 32px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0; margin-top: 2px;
}
.step-text { flex: 1; color: var(--text); line-height: 1.6; }

/* Stars */
.stars { display: flex; gap: 2px; }
.star { font-size: 1rem; cursor: pointer; color: var(--text-faint); transition: color var(--t-fast), transform var(--t-fast); }
.star.filled, .star:hover { color: #fbbf24; }
.star:hover { transform: scale(1.2); }

/* КБЖУ */
.kbzhu-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3);
}

.kbzhu-item {
  background: var(--bg-hover);
  border-radius: var(--radius);
  padding: var(--space-3);
  text-align: center;
}

.kbzhu-value { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.kbzhu-label { font-size: 0.7rem; color: var(--text-faint); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════════════════════
   Finance
   ══════════════════════════════════════════════════════════════════════════════ */

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--t);
}

.account-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--acc-color, var(--accent));
}

.account-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.account-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }

.account-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  background: var(--bg-hover);
}

.account-name { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.account-type { font-size: 0.72rem; color: var(--text-faint); }
.account-balance { font-size: 1.5rem; font-weight: 800; color: var(--text); margin-bottom: var(--space-3); }

.account-mini-stats { display: flex; gap: var(--space-4); }
.account-mini-stat { font-size: 0.75rem; }
.account-mini-stat .ams-label { color: var(--text-faint); }
.account-mini-stat .ams-val { font-weight: 600; }
.ams-income { color: var(--success); }
.ams-expense { color: var(--danger); }

/* Transaction item */
.tx-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  transition: background var(--t-fast);
}

.tx-item:hover { background: var(--bg-hover); }

.tx-cat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-weight: 600; font-size: 0.88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 0.75rem; color: var(--text-faint); }
.tx-amount { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }
.tx-amount.transfer { color: var(--info); }

/* Transaction type segmented control */
.tx-type-selector {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  margin-bottom: var(--space-4);
}

.tx-type-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 2px);
  padding: 9px 8px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.tx-type-btn:hover { background: var(--bg-hover); color: var(--text); }

.tx-type-btn.active { font-weight: 600; box-shadow: var(--shadow-sm); }
.tx-type-btn.active[data-tx-type-btn="expense"] { background: var(--danger-light); color: var(--danger); }
.tx-type-btn.active[data-tx-type-btn="income"]  { background: var(--success-light); color: var(--success); }
.tx-type-btn.active[data-tx-type-btn="transfer"] { background: var(--info-light); color: var(--info); }

/* Goal card */
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--t);
}

.goal-card:hover { box-shadow: var(--shadow); }

.goal-header { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.goal-icon { font-size: 1.6rem; }
.goal-name { font-weight: 700; color: var(--text); }
.goal-deadline { font-size: 0.75rem; color: var(--text-faint); }
.goal-amounts { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--text-muted); margin-bottom: var(--space-2); }
.goal-current { font-weight: 700; color: var(--text); }

/* Debt card */
.debt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex; align-items: center; gap: var(--space-4);
  transition: all var(--t);
}

.debt-card:hover { box-shadow: var(--shadow-sm); }

.debt-direction {
  width: 42px; height: 42px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.debt-direction.owe { background: var(--danger-light); }
.debt-direction.owed { background: var(--success-light); }

.debt-info { flex: 1; min-width: 0; }
.debt-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.debt-desc { font-size: 0.77rem; color: var(--text-faint); }
.debt-amount { font-size: 1.1rem; font-weight: 800; }
.debt-amount.owe { color: var(--danger); }
.debt-amount.owed { color: var(--success); }

/* ══════════════════════════════════════════════════════════════════════════════
   Admin
   ══════════════════════════════════════════════════════════════════════════════ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-hover);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════════════════════════
   Avatar
   ══════════════════════════════════════════════════════════════════════════════ */

.avatar {
  border-radius: var(--radius-full);
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-sm { width: 28px; height: 28px; font-size: 0.75rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.95rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2rem; }

/* ══════════════════════════════════════════════════════════════════════════════
   Tabs
   ══════════════════════════════════════════════════════════════════════════════ */

.tabs {
  display: flex; gap: 4px;
  background: var(--bg-hover);
  padding: 4px;
  border-radius: var(--radius);
  width: fit-content;
}

.tab-btn {
  padding: 6px var(--space-4);
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tab-btn.active, .tab-btn:not(a):checked {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) { color: var(--text); }

/* ══════════════════════════════════════════════════════════════════════════════
   Empty state
   ══════════════════════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-12) var(--space-6);
  gap: var(--space-3);
  text-align: center;
}

.empty-icon { font-size: 3.5rem; opacity: .5; }
.empty-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.empty-text { font-size: 0.875rem; color: var(--text-muted); max-width: 320px; }

/* ══════════════════════════════════════════════════════════════════════════════
   Utilities
   ══════════════════════════════════════════════════════════════════════════════ */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); } .gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.gap-grid { gap: var(--space-4); }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); } .mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.p-4 { padding: var(--space-4); } .p-5 { padding: var(--space-5); }
.text-sm { font-size: 0.875rem; } .text-xs { font-size: 0.78rem; }
.text-muted { color: var(--text-muted); } .text-faint { color: var(--text-faint); }
.text-danger { color: var(--danger); } .text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; } .font-medium { font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }

/* ══════════════════════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1280px) {
  .page-content { max-width: 100%; }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  /* Recipe form: stack columns */
  .recipe-form-grid { grid-template-columns: 1fr !important; }
  .recipe-form-sticky { position: static !important; top: auto !important; }
  /* Finance filter: wrap */
  .tx-filter-row { flex-direction: column; align-items: stretch !important; }
  .tx-filter-row > * { max-width: 100% !important; }
  /* Stats: 1 column */
  .stats-2col { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding-bottom: 76px; }
  .bottom-nav { display: flex; }
  .top-bar { padding: 0 var(--space-4); }
  .page-content { padding: var(--space-4); }
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .kbzhu-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-card { padding: var(--space-6); }
  .recipe-hero { height: 220px; }
  .modal { max-width: 100%; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .stat-value { font-size: 1.4rem; }
  /* Account/Goal/Debt cards: 1 col */
  .goals-grid { grid-template-columns: 1fr !important; }
  /* Debt cards: compact */
  .debt-card { flex-wrap: wrap; }
  /* Budget: 1 col */
  .budgets-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 540px) {
  .recipe-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .account-mini-stats { flex-direction: column; gap: var(--space-1); }
  .page-content { padding: var(--space-3); }
  .top-bar-title { font-size: .95rem; }
  /* Transactions filter: wrap properly */
  #tx-filter-form .flex { flex-direction: column; align-items: stretch; }
  #tx-filter-form .flex > * { max-width: 100% !important; width: 100%; }
  .bottom-nav-item span:last-child { font-size: .6rem; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Scrollbar
   ══════════════════════════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ══════════════════════════════════════════════════════════════════════════════
   Theme toggle button
   ══════════════════════════════════════════════════════════════════════════════ */

.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--t-fast);
  color: var(--text-muted);
}

.theme-toggle:hover { background: var(--bg-hover); color: var(--text); transform: rotate(20deg); }

/* ══════════════════════════════════════════════════════════════════════════════
   View toggle (grid/list)
   ══════════════════════════════════════════════════════════════════════════════ */

.view-toggle {
  display: flex; gap: 4px;
  background: var(--bg-hover);
  padding: 3px;
  border-radius: var(--radius);
}

.view-toggle-btn {
  width: 30px; height: 30px;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: none;
  color: var(--text-faint);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 0.9rem;
}

.view-toggle-btn.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════════════════════════════════════════
   Ingredient/step dynamic input
   ══════════════════════════════════════════════════════════════════════════════ */

.dynamic-list { display: flex; flex-direction: column; gap: var(--space-2); }

.dynamic-item {
  display: flex; gap: var(--space-2); align-items: center;
}

.dynamic-item .form-control { flex: 1; }

.drag-handle { cursor: grab; color: var(--text-faint); padding: 0 4px; }

/* ══════════════════════════════════════════════════════════════════════════════
   Color picker
   ══════════════════════════════════════════════════════════════════════════════ */

.color-swatches {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
}

.color-swatch {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
}

.color-swatch:hover, .color-swatch.active {
  transform: scale(1.2);
  border-color: var(--text);
}

/* ══════════════════════════════════════════════════════════════════════════════
   Pagination
   ══════════════════════════════════════════════════════════════════════════════ */

.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-1); margin-top: var(--space-6);
}

.page-btn {
  min-width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════════════════════
   Chart container
   ══════════════════════════════════════════════════════════════════════════════ */

.chart-wrap {
  position: relative;
  height: 280px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Micro animation helpers
   ══════════════════════════════════════════════════════════════════════════════ */

.fade-in { animation: fade-in-up .3s ease both; }

@keyframes fade-in-up {
  from { opacity:0; transform: translateY(12px); }
  to   { opacity:1; transform: none; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Photo drop-zone
   ══════════════════════════════════════════════════════════════════════════════ */

.photo-drop-zone {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-hover);
  transition: border-color var(--t-fast), background var(--t-fast);
}

.photo-drop-zone:hover,
.photo-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ══════════════════════════════════════════════════════════════════════════════
   Cropper.js overrides
   ══════════════════════════════════════════════════════════════════════════════ */

.cropper-container { max-height: 400px; }
.cropper-view-box, .cropper-face { border-radius: var(--radius-sm); }

/* ══════════════════════════════════════════════════════════════════════════════
   Recipe image — prevent stretching on small screens
   ══════════════════════════════════════════════════════════════════════════════ */

.recipe-card-img {
  height: 200px;
  background: var(--bg-hover);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.recipe-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform var(--t-slow);
}

.recipe-hero img {
  object-position: center;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Goals page redesign
   ══════════════════════════════════════════════════════════════════════════════ */

.goals-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-faint);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.goals-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--t);
  position: relative;
  overflow: hidden;
}

.goal-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--goal-color, var(--accent));
  opacity: .7;
}

.goal-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.goal-card.completed { opacity: .7; }

.goal-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.goal-icon-wrap {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  background: var(--bg-hover);
}

.goal-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  line-height: 1.3;
}

.goal-deadline {
  font-size: .72rem;
  color: var(--text-faint);
  margin-top: 2px;
}

.goal-amounts {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.goal-current {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}

.goal-pct-label {
  font-size: .78rem;
  font-weight: 700;
}

.goal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
}

/* Debt card */
.debt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: all var(--t);
}

.debt-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.debt-card.settled { opacity: .55; }

.debt-direction {
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.debt-direction.owe  { background: var(--danger-light);  color: var(--danger); }
.debt-direction.owed { background: var(--success-light); color: var(--success); }

.debt-info { flex: 1; min-width: 0; }
.debt-name { font-weight: 700; font-size: .92rem; color: var(--text); }
.debt-desc { font-size: .75rem; color: var(--text-faint); margin-top: 2px; }

.debt-amount {
  font-size: 1.15rem;
  font-weight: 800;
  white-space: nowrap;
}
.debt-amount.owe  { color: var(--danger); }
.debt-amount.owed { color: var(--success); }

.debt-badge {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* ══════════════════════════════════════════════════════════════════════════════
   Finance export button
   ══════════════════════════════════════════════════════════════════════════════ */

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 600;
  color: var(--success);
  background: var(--success-light);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
}

.export-btn:hover {
  background: var(--success);
  color: white;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Favorite button active state
   ══════════════════════════════════════════════════════════════════════════════ */

.recipe-card-fav.fav-active { color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════════════════
   Chart containers — more variants
   ══════════════════════════════════════════════════════════════════════════════ */

.chart-wrap-sm  { position: relative; height: 200px; }
.chart-wrap     { position: relative; height: 280px; }
.chart-wrap-lg  { position: relative; height: 360px; }

/* ══════════════════════════════════════════════════════════════════════════════
   Settings page: 2-col grid on wide, 1-col on tablet
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 860px) {
  .settings-grid { grid-template-columns: 1fr !important; }
  .budgets-grid  { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .dashboard-charts { grid-template-columns: 1fr !important; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Sidebar hover expand (collapsed → expanded on hover)
   ══════════════════════════════════════════════════════════════════════════════ */

@media (min-width: 769px) {
  .sidebar .nav-item .nav-label-text,
  .sidebar .sidebar-logo span,
  .sidebar .user-info,
  .sidebar .nav-label { transition: opacity var(--t), width var(--t); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Dashboard main grid — responsive
   ══════════════════════════════════════════════════════════════════════════════ */

.dashboard-main-grid {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
  .dashboard-main-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Desktop-only utility
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .desktop-only { display: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Mobile "More" menu
   ══════════════════════════════════════════════════════════════════════════════ */

.more-menu-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.more-menu-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.more-menu {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: var(--z-sidebar);
  padding: var(--space-2) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 32px rgba(0,0,0,0.12);
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.3s ease;
}
.more-menu.open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.more-menu-handle {
  width: 36px; height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: var(--space-2) auto var(--space-4);
}

.more-menu-title {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--space-3);
}

.more-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: background var(--t-fast), color var(--t-fast);
  background: var(--bg-hover);
}
.more-menu-item:hover,
.more-menu-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.more-menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Only show more-menu on mobile */
@media (min-width: 769px) {
  .more-menu, .more-menu-overlay { visibility: hidden !important; pointer-events: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Comprehensive mobile improvements
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Prevent iOS from zooming on input focus */
  input, select, textarea { font-size: max(16px, 1em) !important; }

  /* Top bar more compact */
  .top-bar { height: 52px; }
  .top-bar-title { font-size: .9rem; }

  /* Page content less padding */
  .page-content { padding: var(--space-3) var(--space-3) var(--space-6); }

  /* Cards less padding on mobile */
  .card-body { padding: var(--space-3) var(--space-4); }

  /* Stat cards compact */
  .stat-card { padding: var(--space-4) var(--space-3); }
  .stat-value { font-size: 1.3rem; }

  /* Tables: horizontal scroll */
  .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Transaction items: tighter */
  .tx-item { padding: var(--space-2) var(--space-1); gap: var(--space-2); }
  .tx-desc { font-size: .85rem; }
  .tx-meta { font-size: .72rem; }
  .tx-amount { font-size: .85rem; }
  .tx-cat-icon { width: 34px; height: 34px; flex-shrink: 0; }

  /* Recipe hero shorter */
  .recipe-hero { height: 200px; }

  /* Recipe cards in grid: ensure images don't overflow */
  .recipe-card-img { height: 150px; }

  /* Finance filter: stack on mobile */
  #tx-filter-form .flex { flex-direction: column; gap: var(--space-2); }
  #tx-filter-form .flex > * { max-width: 100% !important; width: 100%; }
  #tx-filter-form input[type="text"],
  #tx-filter-form select { width: 100%; max-width: 100% !important; }

  /* Date range: side by side */
  #tx-filter-form .flex > div.flex { flex-direction: row; }

  /* Bottom nav items: slightly larger touch target */
  .bottom-nav-item { padding: var(--space-1) var(--space-2); min-width: 52px; }

  /* Modal close: easier to tap */
  .modal-header .btn-icon { width: 40px; height: 40px; }

  /* Account cards in finance: 1 col if needed */
  .account-mini-stats { flex-wrap: wrap; }

  /* Goals / Debt: stack action buttons */
  .debt-card-actions { flex-wrap: wrap; }

  /* Chart heights on mobile */
  .chart-wrap-lg { height: 240px; }
  .chart-wrap { height: 220px; }
  .chart-wrap-sm { height: 180px; }

  /* Hide duplicate top actions icons on mobile to save space */
  .top-bar-actions .export-btn span:last-child { display: none; }
}

@media (max-width: 480px) {
  /* Even smaller screens */
  .top-bar-title { font-size: .85rem; }
  .stat-value { font-size: 1.15rem; }
  .card-header { padding: var(--space-3) var(--space-4); }
  .bottom-nav { gap: 0; }
  .bottom-nav-item { min-width: 44px; padding: var(--space-1); }
  .bottom-nav-item span:last-child { font-size: .58rem; }

  /* Recipe grid: always 1 col */
  .recipe-grid { grid-template-columns: 1fr; }

  /* Form grids: 1 col */
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr !important; }

  /* Buttons in top actions: icon only on very small screens */
  .top-bar-actions .btn-sm:not(.btn-icon):not(.btn-primary) { padding: var(--space-1) var(--space-2); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Touch / tap improvements
   ══════════════════════════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
  /* Tap highlight removal */
  * { -webkit-tap-highlight-color: transparent; }

  /* Larger touch targets for interactive elements */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  .nav-item, .bottom-nav-item { min-height: 44px; }
  .form-control { min-height: 44px; }

  /* Remove hover effects that look broken on touch */
  .recipe-card:hover { transform: none; box-shadow: var(--shadow); }
  .stat-card:hover { transform: none; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Top-bar title: always truncate, shrink when action buttons are present
   ══════════════════════════════════════════════════════════════════════════════ */

.top-bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Recipe detail — responsive 2-col layout
   ══════════════════════════════════════════════════════════════════════════════ */

.recipe-detail-grid {
  grid-template-columns: 1fr 360px;
  align-items: start;
}

.recipe-detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  position: sticky;
  top: 80px;
}

@media (max-width: 768px) {
  /* Single column; sidebar (ingredients) floats before steps on mobile */
  .recipe-detail-grid { grid-template-columns: 1fr; }
  .recipe-detail-sidebar { position: static; order: -1; gap: var(--space-4); }

  /* Recipe hero: compact for mobile */
  .recipe-meta-bar { gap: var(--space-2); padding: var(--space-3); }
  .recipe-meta-block { min-width: 56px; }

  /* Ingredients list: tighter on mobile */
  .ingredient-item { font-size: .85rem; padding: var(--space-2); }

  /* Step list: tighter on mobile */
  .step-item { gap: var(--space-3); }
  .step-text { font-size: .9rem; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Recipe index — filter form responsive
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 540px) {
  /* Expand search and category inputs to full width */
  .recipe-filter-form input[name="q"],
  .recipe-filter-form select[name="category"] {
    flex: 1 1 100%;
    max-width: 100% !important;
  }

  /* Recipe list view: hide category badge to declutter on small screens */
  .recipe-list-item > .flex .badge { display: none; }

  /* Recipe list thumb: slightly smaller on small phones */
  .recipe-list-thumb { width: 52px; height: 52px; font-size: 1.4rem; }

  /* Recipe card image: consistent height on small screens */
  .recipe-card-img { height: 140px; }

  /* Kbzhu grid: always 2 columns (not 4) */
  .kbzhu-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Settings — responsive layout
   ══════════════════════════════════════════════════════════════════════════════ */

.settings-grid {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

@media (max-width: 768px) {
  .settings-grid { grid-template-columns: 1fr; }

  /* Avatar row: horizontal but tighter */
  .avatar-xl { width: 80px; height: 80px; font-size: 1.8rem; }

  /* Members table: allow horizontal scroll */
  .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Settings profile avatar row: wrap on very small */
  .settings-grid .card-body > form > div:first-child { flex-wrap: wrap; }
}

@media (max-width: 400px) {
  .avatar-xl { width: 64px; height: 64px; font-size: 1.5rem; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   Stat cards grid on mobile: 2 cols on medium, 1 col on very small
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 380px) {
  .grid-4 { grid-template-columns: 1fr; }
  .stat-card { padding: var(--space-3); }
  .stat-value { font-size: 1.1rem; }
  .stat-icon { width: 34px; height: 34px; font-size: 1rem; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   General polish: cards, modals, buttons on mobile
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Smooth card border-radius on mobile */
  .card { border-radius: var(--radius); }

  /* Modal: always full-width sheet on mobile */
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

  /* Empty states: compact on mobile */
  .empty-state { padding: var(--space-8) var(--space-4); }
  .empty-icon { font-size: 2.5rem; }
  .empty-title { font-size: 1rem; }

  /* Pagination: compact touch targets */
  .page-btn { min-width: 40px; height: 40px; }

  /* Top-bar actions: don't wrap, clip gracefully */
  .top-bar-actions { flex-shrink: 0; gap: var(--space-1); }

  /* Recipe detail: back link or title in top bar */
  .top-bar { gap: var(--space-2); }
}
