/* =============================================
   CRAFTY CHRONICLES — MATERIAL DESIGN SYSTEM
   ============================================= */

:root {
  --primary: #4A90E2;
  --primary-dark: #357ABD;
  --primary-light: #E8F2FC;
  --secondary: #F5A623;
  --secondary-light: #FEF3E0;
  --accent: #7ED321;
  --accent-light: #EEF8DC;
  --danger: #E53935;
  --danger-light: #FFEBEE;
  --surface: #FFFFFF;
  --background: #F4F6F9;
  --on-primary: #FFFFFF;
  --on-surface: #1A1A2E;
  --on-surface-medium: #555570;
  --on-surface-light: #9090A8;
  --divider: #E8EAF0;
  --card-shadow: 0 2px 12px rgba(74,144,226,0.10), 0 1px 3px rgba(0,0,0,0.07);
  --card-shadow-hover: 0 6px 24px rgba(74,144,226,0.18), 0 2px 8px rgba(0,0,0,0.10);
  --bar-height: 56px;
  --nav-height: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--background);
  color: var(--on-surface);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── Utilities ──────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.ai-btn { color: var(--primary); }

/* ── App Bar ────────────────────────────────── */
.app-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--bar-height);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 4px;
  z-index: 100;
  box-shadow: 0 1px 0 var(--divider), 0 2px 8px rgba(0,0,0,0.06);
}
.app-bar-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--on-surface);
  letter-spacing: -0.2px;
}
.app-bar-actions { display: flex; align-items: center; }
.icon-btn {
  width: 44px; height: 44px;
  border: none; background: transparent;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--on-surface-medium);
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
}
.icon-btn:hover, .icon-btn:active { background: rgba(0,0,0,0.06); }
.icon-btn.danger-icon { color: var(--danger); }
.icon-btn .material-icons-round { font-size: 22px; }

/* ── Search Bar ─────────────────────────────── */
.search-bar-container {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--bar-height);
  background: var(--surface);
  z-index: 101;
  padding: 6px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  animation: slideDown 0.2s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.search-bar {
  height: 44px;
  background: var(--background);
  border-radius: 22px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 14px;
  gap: 8px;
}
.search-bar .material-icons-round { color: var(--on-surface-light); font-size: 20px; }
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: var(--font);
  color: var(--on-surface);
  outline: none;
}

/* ── Drawer ─────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.drawer-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  background: var(--surface);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 40px 20px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  gap: 14px;
}
.drawer-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: white;
  border: 2px solid rgba(255,255,255,0.4);
}
.drawer-name {
  font-size: 16px;
  font-weight: 600;
  color: white;
  display: block;
}
.drawer-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  display: block;
  margin-top: 2px;
}
.drawer-divider {
  height: 1px;
  background: var(--divider);
  margin: 8px 0;
}
.drawer-nav {
  list-style: none;
  flex: 1;
  padding: 8px 0;
}
.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  cursor: pointer;
  color: var(--on-surface-medium);
  font-size: 15px;
  font-weight: 500;
  border-radius: 0 24px 24px 0;
  margin-right: 12px;
  transition: background var(--transition), color var(--transition);
}
.drawer-nav-item:hover, .drawer-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}
.drawer-nav-item .material-icons-round { font-size: 22px; }
.drawer-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  color: var(--on-surface-light);
  font-size: 13px;
}

/* ── Main Content ───────────────────────────── */
.main-content {
  position: fixed;
  top: var(--bar-height);
  left: 0; right: 0;
  bottom: var(--nav-height);
  overflow: hidden;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  background: var(--background);
}
.screen.active { display: flex; flex-direction: column; }
.screen-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.screen-scroll::-webkit-scrollbar { display: none; }

/* Chat screen special layout */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--background);
}

/* ── Bottom Navigation ──────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  display: flex;
  box-shadow: 0 -1px 0 var(--divider), 0 -2px 12px rgba(0,0,0,0.06);
  z-index: 100;
}
.nav-tab {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--on-surface-light);
  transition: color var(--transition);
  position: relative;
  overflow: hidden;
  padding-bottom: 4px;
}
.nav-tab .material-icons-round { font-size: 24px; transition: transform 0.18s; }
.nav-tab.active { color: var(--primary); }
.nav-tab.active .material-icons-round { transform: scale(1.1); }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.nav-tab::after {
  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-tab.active::after { width: 32px; }

/* ── FAB ────────────────────────────────────── */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-height) + 16px);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(74,144,226,0.45);
  cursor: pointer;
  z-index: 98;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(74,144,226,0.55); }
.fab:active { transform: scale(0.95); }
.fab .material-icons-round { font-size: 26px; }
.fab.fab-hidden { transform: scale(0) !important; opacity: 0; pointer-events: none; }

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

/* ── Stats Row ──────────────────────────────── */
.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.stat-card.primary-stat::before { background: var(--primary); }
.stat-card.accent-stat::before { background: var(--accent); }
.stat-card.secondary-stat::before { background: var(--secondary); }
.stat-number {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Section Header ─────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--on-surface);
  letter-spacing: -0.2px;
}
.text-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.text-btn:hover { background: var(--primary-light); }
.text-btn .material-icons-round { font-size: 18px; }

/* ── AI Tip Card ─────────────────────────────── */
.ai-tip-card {
  background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%);
  border: 1.5px solid #4A90E230;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  position: relative;
}
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(90deg, var(--primary), #764ba2);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ai-badge .material-icons-round { font-size: 12px; }
.ai-tip-content { color: var(--on-surface); font-size: 14px; line-height: 1.6; }

/* ── AI Result Card ─────────────────────────── */
.ai-result-card {
  background: var(--primary-light);
  border: 1.5px solid #4A90E240;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}
.ai-result-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--on-surface);
  white-space: pre-wrap;
}

/* ── Skeleton ───────────────────────────────── */
.skeleton-lines { display: flex; flex-direction: column; gap: 8px; }
.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, #e0e4ef 25%, #f0f2f8 50%, #e0e4ef 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: shimmer 1.5s infinite;
}
.skeleton-line.short { width: 60%; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Progress Card ──────────────────────────── */
.progress-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--on-surface-medium);
  width: 80px;
  flex-shrink: 0;
}
.progress-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--background);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.progress-bar.primary-bar { background: var(--primary); }
.progress-bar.accent-bar { background: var(--accent); }
.progress-bar.secondary-bar { background: var(--secondary); }
.progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-light);
  width: 34px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Card List (Recent) ─────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.recent-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.recent-card:active { transform: scale(0.98); box-shadow: var(--card-shadow-hover); }
.recent-card-color {
  width: 5px;
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.recent-card-body { flex: 1; padding-left: 4px; }
.recent-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-card-sub {
  font-size: 12px;
  color: var(--on-surface-light);
}
.recent-card-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: capitalize;
  flex-shrink: 0;
}

/* ── Gallery Grid ───────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.gallery-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
  background: var(--divider);
  transition: transform var(--transition);
}
.gallery-item:active { transform: scale(0.97); }
.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.55) 0%, transparent 60%);
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.gallery-item-title {
  color: white;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Filter Chips ───────────────────────────── */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  border: 1.5px solid var(--divider);
  background: var(--surface);
  color: var(--on-surface-medium);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: var(--font);
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Project List ───────────────────────────── */
.project-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.project-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.project-item:active { transform: scale(0.98); }
.project-item-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
}
.project-item-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.project-item-info { flex: 1; min-width: 0; }
.project-item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-item-desc {
  font-size: 12px;
  color: var(--on-surface-light);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.project-item-date { font-size: 11px; color: var(--on-surface-light); }

/* ── Status Chips ───────────────────────────── */
.status-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: capitalize;
  letter-spacing: 0.2px;
}
.status-planning { background: #E3F2FD; color: #1565C0; }
.status-in-progress { background: #FFF3E0; color: #E65100; }
.status-completed { background: var(--accent-light); color: #33691E; }
.status-on-hold { background: #EFEBE9; color: #4E342E; }

/* ── Supplies Grid ──────────────────────────── */
.supplies-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.supply-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.supply-card:active { transform: scale(0.98); }
.supply-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.supply-info { flex: 1; }
.supply-name { display: block; font-size: 15px; font-weight: 600; color: var(--on-surface); }
.supply-count { display: block; font-size: 12px; color: var(--on-surface-light); margin-top: 2px; }
.supply-arrow { color: var(--on-surface-light); font-size: 20px; }

/* Supply list items */
.supply-list-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}
.supply-list-name { flex: 1; font-size: 14px; font-weight: 500; color: var(--on-surface); }
.supply-list-meta { font-size: 12px; color: var(--on-surface-light); }
.supply-list-del { color: var(--danger); }

/* ── Charts ─────────────────────────────────── */
.chart-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 16px;
  letter-spacing: -0.1px;
}
.chart-container {
  width: 100%;
  overflow-x: auto;
}
.chart-container svg { display: block; }

/* Donut */
.donut-container {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--on-surface-medium);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Progress bars in analytics */
.analytics-progress-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.analytics-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--on-surface-medium);
}
.analytics-progress-bar-wrap {
  height: 8px;
  background: var(--background);
  border-radius: 4px;
  overflow: hidden;
}
.analytics-progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}

/* ── AI Suggest Button ──────────────────────── */
.ai-suggest-btn {
  width: 100%;
  padding: 12px;
  border: 1.5px dashed var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  transition: background var(--transition), transform var(--transition);
}
.ai-suggest-btn:active { transform: scale(0.98); }
.ai-suggest-btn .material-icons-round { font-size: 20px; }

/* ── Retry Button ───────────────────────────── */
.retry-btn {
  margin-top: 10px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}
.retry-btn .material-icons-round { font-size: 16px; }

/* ── Bottom Sheets ──────────────────────────── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.22s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.bottom-sheet {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.28s cubic-bezier(0.4,0,0.2,1);
  -webkit-overflow-scrolling: touch;
}
.bottom-sheet.tall-sheet { max-height: 88vh; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--divider);
  border-radius: 2px;
  margin: 12px auto 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--divider);
}
.sheet-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  color: var(--on-surface);
}
.sheet-header-actions { display: flex; align-items: center; }
.sheet-body { padding: 20px; }
.sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-bottom: 16px;
}

/* ── Floating Label Inputs ──────────────────── */
.input-group {
  position: relative;
  margin-bottom: 20px;
}
.input-group.half { flex: 1; margin-bottom: 0; }
.input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.float-input {
  width: 100%;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 18px 14px 8px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--on-surface);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.float-textarea {
  resize: none;
  padding-top: 20px;
}
.float-select {
  padding-top: 18px;
  cursor: pointer;
}
.date-input { cursor: pointer; }
.float-input:focus { border-color: var(--primary); }
.float-label {
  position: absolute;
  left: 14px;
  top: 14px;
  font-size: 15px;
  color: var(--on-surface-light);
  transition: all 0.18s ease;
  pointer-events: none;
  background: transparent;
}
.float-input:focus ~ .float-label,
.float-input:not(:placeholder-shown) ~ .float-label,
.float-label.always-up {
  top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.3px;
}
.field-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  display: block;
}
.input-group.error .float-input { border-color: var(--danger); }

/* ── Buttons ─────────────────────────────────── */
.btn-primary {
  flex: 1;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline {
  flex: 1;
  padding: 14px;
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-danger {
  flex: 1;
  padding: 14px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-danger:active { transform: scale(0.98); }

/* ── Detail Sheet ───────────────────────────── */
.detail-hero {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--background);
}
.detail-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.detail-hero .status-chip {
  position: absolute;
  bottom: 10px;
  right: 10px;
}
.detail-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}
.detail-row:last-of-type { border-bottom: none; }
.detail-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--on-surface-light);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.detail-value {
  display: block;
  font-size: 15px;
  color: var(--on-surface);
  line-height: 1.5;
}

/* ── Dialog ─────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px 20px;
  width: 100%;
  max-width: 320px;
  animation: scaleIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes scaleIn { from { transform: scale(0.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.dialog-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--danger-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.dialog-icon .material-icons-round { color: var(--danger); font-size: 26px; }
.dialog-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 8px;
}
.dialog-text {
  text-align: center;
  font-size: 14px;
  color: var(--on-surface-medium);
  line-height: 1.5;
  margin-bottom: 20px;
}
.dialog-actions { display: flex; gap: 10px; }

/* ── 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: 64px !important;
  color: var(--divider);
  margin-bottom: 16px;
}
.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 8px;
}
.empty-sub {
  font-size: 14px;
  color: var(--on-surface-light);
  line-height: 1.5;
  margin-bottom: 24px;
  max-width: 260px;
}

/* ── Snackbar ───────────────────────────────── */
.snackbar {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 16px; right: 16px;
  background: #323246;
  color: white;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  z-index: 500;
  transform: translateY(200%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
}
.snackbar.show { transform: translateY(0); opacity: 1; pointer-events: all; }
.snackbar-action {
  background: transparent;
  border: none;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  padding: 4px 8px;
  letter-spacing: 0.5px;
}

/* ── Chat Screen ────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.chat-messages::-webkit-scrollbar { display: none; }
.chat-bubble {
  display: flex;
  gap: 8px;
  max-width: 86%;
  align-items: flex-end;
}
.chat-bubble.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-bubble.ai { align-self: flex-start; }
.bubble-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bubble-avatar .material-icons-round { font-size: 18px; color: var(--primary); }
.bubble-body { display: flex; flex-direction: column; gap: 3px; }
.bubble-content {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
}
.chat-bubble.ai .bubble-content {
  background: var(--surface);
  color: var(--on-surface);
  border-radius: 4px 18px 18px 18px;
  box-shadow: var(--card-shadow);
}
.chat-bubble.user .bubble-content {
  background: var(--primary);
  color: white;
  border-radius: 18px 18px 4px 18px;
}
.bubble-time {
  font-size: 10px;
  color: var(--on-surface-light);
  padding: 0 4px;
}
.chat-bubble.user .bubble-time { text-align: right; }
.chat-input-area {
  background: var(--surface);
  border-top: 1px solid var(--divider);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.chat-input {
  flex: 1;
  border: 1.5px solid var(--divider);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--on-surface);
  background: var(--background);
  outline: none;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
.chat-send-btn:active { transform: scale(0.92); }
.chat-send-btn .material-icons-round { font-size: 20px; }

/* ── AI Loading Spinner ─────────────────────── */
.ai-spinner {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
}
.spinner-dots {
  display: flex;
  gap: 4px;
}
.spinner-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: dotBounce 1.2s infinite ease-in-out;
}
.spinner-dot:nth-child(2) { animation-delay: 0.2s; }
.spinner-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Ripple ─────────────────────────────────── */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: rippleAnim 0.55s ease-out;
  pointer-events: none;
}
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* ── SVG Chart Helpers ──────────────────────── */
.chart-bar-label { font-family: var(--font); }
.chart-axis-line { stroke: var(--divider); stroke-width: 1; }

/* ── Transitions between screens ───────────── */
.screen { transition: opacity 0.18s ease; }
.screen:not(.active) { opacity: 0; }
.screen.active { opacity: 1; }
