:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --accent: #ef4444;
  --accent-light: #fee2e2;
  --bg: #f0f9ff;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #e0f2fe;
  --shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1), 0 2px 4px -1px rgba(59, 130, 246, 0.06);
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 90px;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
  color: white;
  padding: 1.75rem 1rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-top: 0.5rem;
}

.logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 0.25rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.back-home {
  display: inline-block;
  color: white;
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}
.back-home:hover { opacity: 1; text-decoration: underline; }

.info-bar {
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: #1e40af;
}
.info-bar p { max-width: 640px; margin: 0 auto; }

.install-banner {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-bottom: 1px solid #bfdbfe;
  padding: 0.85rem 1rem;
  position: relative;
}

.install-content {
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  padding-right: 2rem;
}

.install-content strong {
  color: var(--primary-dark);
  font-size: 0.95rem;
}

.install-content p {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.2rem;
}

.close-install {
  position: absolute;
  top: 0;
  right: 0;
  width: auto;
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 1.2rem;
  padding: 0.25rem 0.5rem;
  margin: 0;
  cursor: pointer;
}

.close-install:hover {
  color: var(--text);
  background: transparent;
  transform: none;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.25rem;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 1.25rem;
  color: var(--primary-dark);
  font-weight: 600;
}

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

.list-header h2 { margin-bottom: 0; }

input, button {
  width: 100%;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

button.secondary {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 0;
}

button.secondary:hover {
  background: var(--primary-light);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
}

.form-actions button { margin-bottom: 0; }

#cancel-edit {
  background: #f1f5f9;
  color: var(--text);
}

.photo-area {
  margin-bottom: 0.85rem;
}

.photo-buttons {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.photo-buttons button {
  flex: 1;
  margin-bottom: 0;
  font-size: 0.9rem;
  padding: 0.75rem 0.5rem;
}

#preview {
  max-width: 100%;
  margin-top: 0.85rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

#filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

#filters button {
  flex: 1;
  min-width: 70px;
  background: #f8fafc;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.6rem;
  margin-bottom: 0;
  border: 1.5px solid transparent;
}

#filters button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.product-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  margin-bottom: 0.85rem;
  background: white;
  transition: all 0.2s;
  position: relative;
}

.product-card:hover {
  box-shadow: var(--shadow);
  border-color: #bfdbfe;
}

.product-card h3 {
  font-size: 1.08rem;
  margin-bottom: 0.4rem;
  color: var(--text);
  padding-right: 80px;
}

.product-card .meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.card-actions {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.4rem;
}

.card-actions button {
  width: auto;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  margin: 0;
  border-radius: 8px;
}

.btn-edit {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.btn-delete {
  background: var(--accent-light);
  color: var(--danger);
}

.progress {
  height: 8px;
  background: #e0f2fe;
  border-radius: 4px;
  margin: 0.6rem 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #34d399);
  transition: width 0.4s ease;
  border-radius: 4px;
}

.progress-bar.warning { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #f87171); }
.progress-bar.expired { background: var(--danger); }

.status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  display: inline-block;
  margin-top: 0.3rem;
}

.status.active { background: #d1fae5; color: #065f46; }
.status.expiring { background: #fef3c7; color: #92400e; }
.status.expired { background: #fee2e2; color: #991b1b; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}
.alert.expired {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid #ef4444;
}
.alert.expiring {
  background: #fef3c7;
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  padding: 0.85rem;
  text-align: center;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  border-top: 1px solid var(--border);
}

.coffee-btn {
  display: inline-block;
  background: linear-gradient(135deg, #ef4444, #f87171);
  color: white;
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  transition: transform 0.2s;
}

.coffee-btn:hover {
  transform: translateY(-2px);
}

@media (min-width: 600px) {
  main { padding: 1.5rem; }
  header h1 { font-size: 2rem; }
}