:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --border: #d8dcd5;
  --border-strong: #b6bdae;
  --text: #1f2a1c;
  --text-muted: #5b6655;
  --accent: #3f7d3a;
  --accent-hover: #336330;
  --accent-soft: #e7f1e3;
  --danger: #b3261e;
  --danger-soft: #fbeae9;
  --shadow: 0 2px 6px rgba(20, 35, 18, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1.25rem 1.25rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--accent);
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 0.75rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
}

footer code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

/* Search ------------------------------------------------------------- */
.search-section { position: relative; }

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#search-input {
  width: 100%;
  font-size: 1.05rem;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.clear-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
}

.clear-btn:hover { background: var(--accent-soft); color: var(--text); }

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 360px;
  overflow-y: auto;
  z-index: 10;
}

.suggestions li {
  padding: 0.65rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.suggestions li:last-child { border-bottom: none; }

.suggestions li:hover,
.suggestions li[aria-selected="true"] {
  background: var(--accent-soft);
}

.suggestions .suggestion-primary {
  font-weight: 600;
}

.suggestions .suggestion-secondary {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.suggestions .suggestion-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}

.suggestion-tag {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.suggestions li.already-selected {
  opacity: 0.55;
  cursor: default;
}

.suggestions li.already-selected::after {
  content: "✓ bereits gewählt";
  font-size: 0.8rem;
  color: var(--accent);
}

.status {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

/* Selection ---------------------------------------------------------- */
.selection-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

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

.selection-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.count {
  color: var(--text-muted);
  font-weight: normal;
}

.selection-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button {
  font: inherit;
  cursor: pointer;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled {
  background: #c5ccc1;
  border-color: #c5ccc1;
  cursor: not-allowed;
}

button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

button.secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--text-muted);
  color: var(--text);
}

button.secondary:disabled {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}

.selection-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.selection-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.selection-list .plant-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.selection-list .plant-info .primary {
  font-weight: 600;
}

.selection-list .plant-info .secondary {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.selection-list .remove-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 0.25rem 0.55rem;
  font-size: 1rem;
  border-radius: var(--radius);
}

.selection-list .remove-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.empty-state {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 0.5rem 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Header-Zeile mit Logout ------------------------------------------- */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.logout-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  white-space: nowrap;
  flex-shrink: 0;
}

.logout-link:hover {
  background: var(--bg);
  color: var(--text);
}

/* Upload-Bereich ----------------------------------------------------- */
.upload-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.upload-section h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.upload-hint {
  margin: 0 0 0.9rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

#upload-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

#upload-file {
  flex: 1;
  min-width: 200px;
  font: inherit;
}

.upload-status {
  margin-top: 0.7rem;
  font-size: 0.9rem;
  min-height: 1.2em;
  color: var(--text-muted);
}

.upload-status.success {
  color: var(--accent);
  font-weight: 500;
}

.upload-status.error {
  color: var(--danger);
  font-weight: 500;
}

/* Login-Seite -------------------------------------------------------- */
.login-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
}

.login-box h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--accent);
  text-align: center;
}

.login-subtitle {
  margin: 0.25rem 0 1.25rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
}

.login-box label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.login-box input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.login-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-box button {
  margin-top: 0.25rem;
}

.login-error {
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 540px) {
  main { padding: 1rem 0.75rem; }
  header { padding: 1rem 0.75rem; }
  .selection-section { padding: 1rem; }
  .upload-section { padding: 1rem; }
  .selection-header h2 { font-size: 1rem; }
  button { padding: 0.5rem 0.9rem; }
}
