:root {
  --green: #4a7c59;
  --green-dark: #2f5233;
  --orange: #c05621;
  --bg: #f7f5f0;
  --card-bg: #ffffff;
  --border: #ddd6c8;
  --text: #23291f;
  --muted: #6b7367;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  background: var(--green-dark);
  color: #fff;
  padding: 1.25rem 1.5rem;
}
.app-header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.app-header .subtitle { margin: 0; opacity: 0.85; font-size: 0.9rem; max-width: 60rem; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.75rem 1.5rem 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
}
.tab-btn.active {
  background: var(--bg);
  color: var(--green-dark);
  font-weight: 600;
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--bg);
  margin-bottom: -1px;
}

main { padding: 1.5rem; max-width: 1000px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

h2 { color: var(--green-dark); margin-top: 0; }
.muted { color: var(--muted); font-size: 0.88rem; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 0.75rem 0;
}
.row label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  gap: 0.25rem;
  color: var(--muted);
}
input, select, button {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
input, select { min-width: 9rem; }
button {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  cursor: pointer;
}
button:hover { background: var(--green-dark); border-color: var(--green-dark); }
button.danger { background: #b23b3b; border-color: #b23b3b; }
button.danger:hover { background: #8f2e2e; }
button.tool-btn { background: #fff; color: var(--text); border-color: var(--border); }
button.tool-btn.active { background: var(--orange); border-color: var(--orange); color: #fff; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}

.summary-card {
  background: #eef3ea;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.summary-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; margin: 0; }
.summary-card dt { color: var(--muted); }
.summary-card dd { margin: 0; font-weight: 600; }

.hidden { display: none !important; }

.result-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.result-list li {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.result-list li button { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.result-list li.clickable { cursor: pointer; }
.result-list li.clickable:hover { border-color: var(--green); }

.toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; }

canvas {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  max-width: 100%;
  display: block;
  cursor: crosshair;
}

.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0.75rem 0; }
.legend .legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.legend .swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.plant-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  background: #fff;
}
.plant-card.feasible { border-left: 5px solid var(--green); }
.plant-card.partial { border-left: 5px solid var(--orange); }
.plant-card.not_feasible { border-left: 5px solid #b23b3b; }
.plant-card h4 { margin: 0 0 0.25rem; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  margin-left: 0.5rem;
}
.badge.feasible { background: var(--green); }
.badge.partial { background: var(--orange); }
.badge.not_feasible { background: #b23b3b; }
.plant-card ul { margin: 0.4rem 0 0; padding-left: 1.2rem; font-size: 0.85rem; }
.warn { color: #8a4a12; }
.schedule-line { font-size: 0.85rem; color: var(--text); margin: 0.15rem 0; }

.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.explore-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.explore-card.feasible { border-left: 4px solid var(--green); }
.explore-card.partial { border-left: 4px solid var(--orange); }
.explore-card.not_feasible { border-left: 4px solid #b23b3b; }
.explore-card h4 { margin: 0; font-size: 0.95rem; }
.explore-card .explore-facts { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.explore-card button { align-self: flex-start; font-size: 0.8rem; padding: 0.3rem 0.6rem; margin-top: 0.2rem; }

.table-scroll { overflow-x: auto; margin-top: 0.75rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th, .data-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table td.plant-name { font-weight: 600; white-space: normal; }
.data-table td button { font-size: 0.78rem; padding: 0.3rem 0.6rem; }

.app-footer {
  padding: 1rem 1.5rem 2rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  max-width: 1000px;
  margin: 0 auto;
}
