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

:root {
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --orange: #ef6c00;
  --orange-light: #fff3e0;
  --red: #c62828;
  --red-light: #ffebee;
  --blue: #1565c0;
  --blue-light: #e3f2fd;
  --gray: #666;
  --gray-light: #f5f5f5;
  --text: #222;
  --bg: #fafafa;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

h1 { font-size: 1.4rem; margin-bottom: 16px; }
h2 { font-size: 1.1rem; margin-bottom: 12px; }
h3 { font-size: 0.95rem; color: var(--gray); margin: 16px 0 8px; }

a { color: var(--blue); text-decoration: none; }

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.header h1 { margin: 0; }
.header a { font-size: 0.9rem; }

/* Alert banner */
.alert-banner {
  background: var(--red-light);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--red);
}
.alert-banner:empty { display: none; }

/* Plant cards */
.plant-card {
  background: white;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.plant-card:active { box-shadow: 0 1px 4px rgba(0,0,0,0.15); }

.plant-card img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--gray-light);
}
.plant-card .no-photo {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  background: var(--gray-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.plant-info { flex: 1; }
.plant-name { font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.plant-stats { font-size: 0.82rem; color: var(--gray); line-height: 1.5; }

.health-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.health-good { background: var(--green-light); color: var(--green); }
.health-warn { background: var(--orange-light); color: var(--orange); }
.health-bad { background: var(--red-light); color: var(--red); }

.badge-recovery {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 0.7rem;
  background: var(--blue-light);
  color: var(--blue);
}

/* Environment bar */
.env-bar {
  background: white;
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: var(--gray);
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* Detail page */
.detail-photo {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 14px;
  background: var(--gray-light);
}

.ai-summary {
  background: var(--green-light);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.chart-container {
  background: white;
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 12px;
  margin-bottom: 14px;
}
.chart-container canvas { width: 100% !important; height: 200px !important; }

.log-table {
  width: 100%;
  font-size: 0.8rem;
  border-collapse: collapse;
}
.log-table th { text-align: left; color: var(--gray); font-weight: 500; padding: 6px 4px; }
.log-table td { padding: 6px 4px; border-top: 1px solid #eee; }

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  min-width: 120px;
}
.btn-primary { background: var(--blue); color: white; }
.btn-secondary { background: var(--gray-light); color: var(--text); }
.btn:active { opacity: 0.8; }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

.toggle {
  width: 44px;
  height: 24px;
  background: #ccc;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle.on { background: var(--green); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: left 0.2s;
}
.toggle.on::after { left: 22px; }

input[type="range"] { width: 100%; margin: 8px 0; }
textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
}

/* Photo gallery */
.photo-gallery {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.photo-gallery img {
  width: 70px;
  height: 70px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray);
}

/* Login */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
}
.login-page input {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  width: 260px;
}
