:root {
  --green-900: #1e5128;
  --green-800: #2e7d32;
  --green-100: #e8f5e9;
  --amber-700: #f57c00;
  --red-700: #d32f2f;
  --blue-700: #1976d2;
  --grey-900: #212121;
  --grey-600: #757575;
  --grey-200: #eeeeee;
  --radius: 12px;
  --shadow: 0 2px 6px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--grey-900);
  background: #f6f7f6;
  line-height: 1.45;
}

.app-header {
  background: var(--green-900);
  color: white;
  padding: 1rem;
  text-align: center;
}
.app-header h1 { margin: 0; font-size: 1.35rem; }
.app-header .subtitle { margin: 0.25rem 0 0; opacity: 0.9; font-size: 0.85rem; }

.container { padding: 1rem; max-width: 960px; margin: 0 auto; }

.controls {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

#search {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  font-size: 1rem;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}
.filters select {
  padding: 0.6rem;
  border-radius: var(--radius);
  border: 1px solid #ccc;
  font-size: 0.95rem;
  background: white;
}

.stats {
  font-size: 0.85rem;
  color: var(--grey-600);
  margin-bottom: 1rem;
}

.plant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  cursor: pointer;
  transition: transform 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card:hover, .card:focus { transform: translateY(-2px); outline: none; }
.card .primary-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-900);
  margin: 0;
}
.card .secondary-name { font-size: 0.9rem; color: var(--grey-600); margin: 0; }
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
}
.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--grey-200);
  color: var(--grey-900);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.category-crop { background: #fff3e0; color: var(--amber-700); }
.badge.category-medicinal { background: #e3f2fd; color: var(--blue-700); }
.badge.category-endemic { background: #e8f5e9; color: var(--green-800); }
.badge.category-invasive { background: #ffebee; color: var(--red-700); }
.badge.category-forage { background: #f3e5f5; color: #7b1fa2; }
.badge.category-native { background: #e0f2f1; color: #00695c; }
.badge.priority-high { background: var(--red-700); color: white; }
.badge.priority-medium { background: var(--amber-700); color: white; }
.badge.priority-low { background: var(--grey-600); color: white; }

.no-image {
  background: var(--grey-200);
  border-radius: 8px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-600);
  font-size: 0.85rem;
}

.detail-panel {
  position: fixed;
  inset: 0;
  background: white;
  z-index: 100;
  overflow-y: auto;
  padding: 1rem;
  animation: slideIn 0.18s ease-out;
}
.detail-panel.hidden { display: none; }

@keyframes slideIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.close-btn {
  background: var(--green-900);
  color: white;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 1rem;
}

.detail-content h2 { margin: 0 0 0.25rem; color: var(--green-900); }
.detail-content .names { color: var(--grey-600); margin-bottom: 1rem; }
.detail-content dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  margin: 1rem 0;
}
.detail-content dt { font-weight: 700; color: var(--grey-900); }
.detail-content dd { margin: 0; }

.warning-box {
  background: #ffebee;
  border-left: 4px solid var(--red-700);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
}

.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--grey-600);
  padding: 1.5rem 1rem;
}

@media (min-width: 640px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
  .detail-panel { padding: 2rem; }
  .detail-content { max-width: 720px; margin: 0 auto; }
}
