/* =====================================================
   FRUGAL FINDS - Mobile App CSS
   Material Design + Native App Feel
   ===================================================== */

/* ---- CSS Variables ---- */
:root {
  --primary: #4CAF50;
  --primary-dark: #388E3C;
  --primary-light: #C8E6C9;
  --secondary: #8BC34A;
  --accent: #CDDC39;
  --accent-dark: #AFB42B;

  --bg: #F5F7F5;
  --surface: #FFFFFF;
  --surface-2: #F0F4F0;

  --text-primary: #1A2E1A;
  --text-secondary: #5A7A5A;
  --text-hint: #9EB89E;
  --text-on-primary: #FFFFFF;

  --divider: #E0EAE0;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.18);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --nav-height: 60px;
  --appbar-height: 56px;
  --transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ---- Top App Bar ---- */
.top-app-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--appbar-height);
  background: var(--primary);
  color: var(--text-on-primary);
  display: flex;
  align-items: center;
  padding: 0 4px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(76,175,80,0.3);
}

.top-app-bar-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
}

/* ---- Search Bar ---- */
.search-bar-container {
  position: fixed;
  top: var(--appbar-height);
  left: 0; right: 0;
  background: var(--surface);
  padding: 8px 16px;
  z-index: 99;
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--divider);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 24px;
  padding: 8px 14px;
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
}

/* ---- Icon Button ---- */
.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: background var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover { background: rgba(255,255,255,0.15); }
.icon-btn:active { background: rgba(255,255,255,0.25); }

/* ---- Side Drawer ---- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  pointer-events: none;
  transition: background var(--transition);
}

.drawer-backdrop.open {
  background: rgba(0,0,0,0.5);
  pointer-events: all;
}

.side-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--surface);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  padding: 48px 20px 24px;
  color: white;
}

.drawer-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.drawer-logo-icon {
  font-size: 36px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.drawer-app-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.drawer-app-sub {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

.drawer-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 16px 20px 6px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
  border-radius: 0;
}

.drawer-item:hover, .drawer-item:active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.drawer-item-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.drawer-divider {
  height: 1px;
  background: var(--divider);
  margin: 8px 20px;
}

/* ---- Main Content ---- */
.main-content {
  position: fixed;
  top: var(--appbar-height);
  bottom: var(--nav-height);
  left: 0; right: 0;
  overflow: hidden;
}

/* ---- Screens ---- */
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity var(--transition), transform var(--transition);
  overflow: hidden;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateX(0);
  z-index: 10;
}

.screen-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.drawer-screen {
  position: absolute !important;
  inset: 0 !important;
  display: none !important;
  flex-direction: column !important;
  z-index: -1 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.drawer-screen.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: all !important;
  transform: translateX(0) !important;
  z-index: 50 !important;
  visibility: visible !important;
}

.drawer-screen .screen-scroll {
  padding-top: 4px;
}

/* ---- Chat Screen ---- */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
  pointer-events: auto;
  z-index: 10;
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--divider);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--surface-2);
  color: var(--text-primary);
  transition: border-color var(--transition);
  pointer-events: auto !important;
  z-index: 11;
}

.chat-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto !important;
  z-index: 11;
  flex-shrink: 0;
  transition: transform var(--transition), background var(--transition);
}

.chat-send-btn:active { transform: scale(0.9); }
.chat-send-btn:hover { background: var(--primary-dark); }

/* Chat Bubbles */
.chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.chat-bubble.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-bubble.ai {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble-content {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble.user .bubble-content {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble.ai .bubble-content {
  background: var(--surface);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.bubble-time {
  font-size: 11px;
  color: var(--text-hint);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  width: fit-content;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  background: var(--text-hint);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Bottom Navigation ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--divider);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  transition: color var(--transition);
  min-width: 44px;
  position: relative;
  padding: 6px 0;
}

.nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
  transition: width var(--transition);
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::before {
  width: 40px;
}

.nav-icon {
  width: 24px;
  height: 24px;
}

.nav-label {
  letter-spacing: 0.3px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 12px;
}

/* ---- Stats Row ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

/* ---- Section Header ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 8px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.text-btn:hover { background: var(--primary-light); }

/* ---- AI Card ---- */
.ai-card {
  background: linear-gradient(135deg, #E8F5E9 0%, #F1F8E9 100%);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid #C8E6C9;
  position: relative;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.ai-card p, .ai-card div {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* ---- AI Action Row ---- */
.ai-action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ai-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: 24px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.ai-action-btn:hover, .ai-action-btn:active {
  background: var(--primary);
  color: white;
}

.ai-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Loading Spinner ---- */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 4px 0;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Skeleton ---- */
.skeleton-block {
  background: linear-gradient(90deg, #E0E0E0 25%, #F0F0F0 50%, #E0E0E0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  margin-bottom: 6px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Quick Actions Grid ---- */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.quick-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.quick-action-btn:active {
  transform: translateY(0);
}

.quick-action-icon {
  font-size: 22px;
}

/* ---- Budget Snapshot ---- */
.budget-snapshot-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.budget-bar-wrap {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--divider);
}

.budget-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.6s ease;
}

.budget-bar-fill.over {
  background: linear-gradient(90deg, #ef5350, #e53935);
}

.budget-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- Budget Summary Card ---- */
.budget-summary-card {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  color: white;
  box-shadow: 0 4px 20px rgba(76,175,80,0.3);
}

.budget-total-label {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.budget-total-value {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.budget-progress-wrap {
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.budget-progress-fill {
  height: 100%;
  background: white;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.budget-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  opacity: 0.9;
}

.budget-sub { font-weight: 400; }

.budget-status {
  background: rgba(255,255,255,0.2);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ---- Filter Chips ---- */
.filter-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--divider);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.chip.active, .chip:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ---- Items List ---- */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.item-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--divider);
  position: relative;
  overflow: hidden;
}

.item-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.item-card:active {
  transform: scale(0.98);
}

.item-priority-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.priority-1 { background: #f44336; }
.priority-2 { background: #FF9800; }
.priority-3 { background: var(--primary); }

.item-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 1.5px solid var(--divider);
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.item-meta-tag {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 2px;
}

.item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.item-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background var(--transition);
}

.item-action-btn:hover { background: var(--surface-2); }

.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.priority-badge.p1 { background: #FFEBEE; color: #c62828; }
.priority-badge.p2 { background: #FFF3E0; color: #e65100; }
.priority-badge.p3 { background: #E8F5E9; color: #2e7d32; }

/* ---- Store Breakdown ---- */
.store-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.store-breakdown-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
}

.store-breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.store-breakdown-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.store-breakdown-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.store-mini-bar-wrap {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.store-mini-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
}

/* ---- Price Comparison ---- */
.price-comparison-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.price-compare-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
}

.price-compare-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.price-compare-stores {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.price-compare-store {
  font-size: 12px;
  color: var(--text-secondary);
}

.price-compare-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.price-compare-price.best {
  color: var(--primary);
}

.best-badge {
  font-size: 10px;
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

/* ---- Stores Grid ---- */
.stores-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.store-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--divider);
  cursor: pointer;
  transition: all var(--transition);
}

.store-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.store-card-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.store-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.store-card-count {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ---- Charts ---- */
.chart-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chart-card.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- Adherence List ---- */
.adherence-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.adherence-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.adherence-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.adherence-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adherence-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  margin-left: 8px;
}

.adherence-bar-wrap {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.adherence-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.6s ease;
}

/* ---- Drawer Screen Header ---- */
.drawer-screen-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--divider);
  margin-bottom: 4px;
}

.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
}

.back-btn:hover { background: var(--surface-2); }

/* ---- Bottom Sheet ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 300;
  pointer-events: none;
  transition: background var(--transition);
}

.modal-backdrop.open {
  background: rgba(0,0,0,0.5);
  pointer-events: all;
}

.bottom-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 301;
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: none;
}

.bottom-sheet.open {
  transform: translateY(0);
  pointer-events: all;
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  margin: 12px auto 0;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--divider);
}

.bottom-sheet-body {
  padding: 20px;
}

/* ---- Forms ---- */
.form-field {
  position: relative;
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-input {
  width: 100%;
  padding: 16px 12px 8px;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
  pointer-events: auto;
}

.form-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.form-label {
  position: absolute;
  left: 12px;
  top: 12px;
  font-size: 14px;
  color: var(--text-hint);
  transition: all var(--transition);
  pointer-events: none;
  background: transparent;
}

.form-input:focus ~ .form-label,
.form-input:not(:placeholder-shown) ~ .form-label,
.form-label-active {
  top: 4px;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

.form-select {
  padding-top: 16px;
  cursor: pointer;
}

/* ---- Icon Picker ---- */
.icon-picker-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.icon-picker-btn {
  padding: 12px;
  border: 2px solid var(--divider);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 24px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.icon-picker-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.05);
}

.icon-picker-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(76,175,80,0.3);
}

.form-error {
  display: block;
  font-size: 11px;
  color: #f44336;
  margin-top: 4px;
  padding-left: 12px;
  min-height: 14px;
}

.form-input.error {
  border-color: #f44336;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ---- Buttons ---- */
.btn-primary {
  flex: 1;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 48px;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-outline {
  flex: 1;
  padding: 14px;
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 48px;
}

.btn-outline:hover { background: var(--primary-light); }
.btn-outline:active { transform: scale(0.97); }

.btn-danger {
  flex: 1;
  padding: 14px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 48px;
}

.btn-danger:hover { background: #d32f2f; }
.btn-danger:active { transform: scale(0.97); }

/* ---- Confirm Dialog ---- */
.confirm-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: calc(100% - 60px);
  max-width: 320px;
  z-index: 302;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 260ms cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
}

.confirm-dialog.open {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

.confirm-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.confirm-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.confirm-message {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

/* ---- AI Suggest Button ---- */
.ai-suggest-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #E8F5E9, #F1F8E9);
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-sm);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all var(--transition);
  justify-content: center;
}

.ai-suggest-btn:hover {
  background: var(--primary-light);
}

/* ---- Suggestions List ---- */
.suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.suggestion-item {
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--divider);
  transition: all var(--transition);
  color: var(--text-primary);
}

.suggestion-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  filter: saturate(0.5);
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
  max-width: 240px;
}

/* ---- Snackbar ---- */
.snackbar {
  position: fixed;
  bottom: calc(var(--nav-height) + 72px);
  left: 16px;
  right: 16px;
  background: #323232;
  color: white;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 400;
  transform: translateY(120%);
  opacity: 0;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.snackbar.show {
  transform: translateY(0);
  opacity: 1;
}

/* ---- Ripple Effect ---- */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.ripple:active::after {
  opacity: 1;
}

/* ---- Detail Sheet ---- */
.detail-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.detail-field:last-of-type {
  border-bottom: none;
}

.detail-field-icon {
  font-size: 20px;
  width: 32px;
  text-align: center;
}

.detail-field-content {
  flex: 1;
}

.detail-field-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-field-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ---- Budget Alert ---- */
.budget-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFEBEE;
  border: 1px solid #FFCDD2;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #c62828;
  font-weight: 500;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--divider);
  border-radius: 2px;
}

/* ---- Budget Modal (New) ---- */
#budgetOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

#budgetOverlay.visible {
  display: block;
}

#budgetDialog {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  z-index: 1001;
  max-height: 60vh;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.1);
}

#budgetDialog.visible {
  display: flex;
  flex-direction: column;
}

#budgetHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--divider);
}

#budgetHeader h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

#budgetCloseBtn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#budgetContent {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#budgetInput {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--divider);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  outline: none;
}

#budgetInput:focus {
  border-color: var(--primary);
  background: var(--surface);
}

#budgetActions {
  display: flex;
  gap: 12px;
}

#budgetActions button {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 200ms ease;
  min-height: 48px;
}

#budgetCancelBtn {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--divider);
}

#budgetCancelBtn:active {
  background: var(--divider);
}

#budgetSaveBtn {
  background: var(--primary);
  color: white;
}

#budgetSaveBtn:active {
  opacity: 0.8;
}

/* ---- Add Store Modal ---- */
#addStoreOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

#addStoreOverlay.visible {
  display: block;
}

#addStoreDialog {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  z-index: 1001;
  max-height: 60vh;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.1);
}

#addStoreDialog.visible {
  display: flex;
  flex-direction: column;
}

#addStoreHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--divider);
}

#addStoreHeader h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

#addStoreCloseBtn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#addStoreContent {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#storeNameInput {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--divider);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  outline: none;
}

#storeNameInput:focus {
  border-color: var(--primary);
  background: var(--surface);
}

#addStoreActions {
  display: flex;
  gap: 12px;
}

#addStoreActions button {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 200ms ease;
  min-height: 48px;
}

#addStoreCancelBtn {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--divider);
}

#addStoreCancelBtn:active {
  background: var(--divider);
}

#addStoreSaveBtn {
  background: var(--primary);
  color: white;
}

#addStoreSaveBtn:active {
  opacity: 0.8;
}

/* ---- Utility ---- */
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-muted { color: var(--text-secondary); }
