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

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

#app { max-width: 500px; margin: 0 auto; padding: 1rem; }

header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 { font-size: 1.5rem; }
#user-name { font-size: 0.9rem; opacity: 0.9; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

input, select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

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

.btn-primary, .btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 6px;
  background: var(--primary-light);
  color: white;
  border: none;
  cursor: pointer;
}

.row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.row select, .row button { flex: 1; margin-bottom: 0; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.action-btn {
  padding: 1rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s;
}

.action-btn:hover { background: #e2e8f0; transform: translateY(-2px); }

.section { display: none; }

/* Forecast Result */
#forecast-result { margin-top: 1rem; }

.forecast-card {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  color: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
}

.forecast-score {
  font-size: 3rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.forecast-species { font-size: 1.2rem; opacity: 0.9; margin-bottom: 1rem; }
.forecast-summary { font-size: 0.95rem; line-height: 1.5; margin-bottom: 1rem; }

.forecast-factors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  text-align: left;
  font-size: 0.85rem;
}

.factor {
  background: rgba(255,255,255,0.15);
  padding: 0.5rem;
  border-radius: 6px;
}

.factor-label { opacity: 0.8; font-size: 0.75rem; }
.factor-value { font-weight: 600; }

.best-times {
  margin-top: 1rem;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* List Items */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.list-item:last-child { border-bottom: none; }
.list-item-title { font-weight: 500; }
.list-item-sub { font-size: 0.85rem; color: var(--text-muted); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  padding: 1rem;
  overflow-y: auto;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  margin: 2rem auto;
}

.modal-content h3 { margin-bottom: 1rem; }

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

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

/* PWA Install Banner */
.install-banner {
  background: var(--primary);
  color: white;
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (display-mode: standalone) {
  .install-banner { display: none; }
}

/* Multi-select species */
.species-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.species-checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: #f3f4f6;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.species-checkboxes label:has(input:checked) {
  background: #dbeafe;
  border: 1px solid #3b82f6;
}
.species-checkboxes input[type="checkbox"] {
  width: 18px;
  height: 18px;
}
.btn-wide {
  width: 100%;
  margin-top: 8px;
}

/* Forecast table */
.forecast-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 14px;
}
.forecast-table th,
.forecast-table td {
  padding: 10px 6px;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}
.forecast-table th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 12px;
}
.forecast-table th:first-child,
.forecast-table td:first-child {
  text-align: left;
}
.forecast-table tr.score-5 { background: #dcfce7; }
.forecast-table tr.score-4 { background: #ecfccb; }
.forecast-table tr.score-3 { background: #fef9c3; }
.forecast-table tr.score-2 { background: #fee2e2; }
.forecast-table tr.score-1 { background: #fecaca; }
.forecast-table tr.error-row { background: #f3f4f6; color: #9ca3af; }

/* List item with actions */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.list-item-content {
  flex: 1;
}
.list-item-actions {
  display: flex;
  gap: 4px;
}
.btn-icon {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  font-size: 16px;
  border-radius: 4px;
}
.btn-icon:hover {
  background: #f3f4f6;
}
.btn-icon.btn-danger:hover {
  background: #fee2e2;
}
