:root {
  --bg: #f7f5ef;
  --card: #ffffff;
  --text: #2a3a1e;
  --muted: #6b7a5a;
  --primary: #5c8a3a;
  --primary-dark: #3f6522;
  --danger: #b5442f;
  --border: #dcd8ca;
}

* { box-sizing: border-box; }

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

header {
  background: var(--primary);
  color: white;
  padding: 0.9rem 1.2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

header nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  max-width: 820px;
  margin: 0 auto;
}

header a {
  color: white;
  text-decoration: none;
  font-weight: 500;
}

header .logo {
  font-size: 1.25rem;
  margin-right: auto;
  font-weight: 600;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

h1 { margin-top: 0.5rem; color: var(--primary-dark); }
h2 { margin: 0; }

.actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 1rem 0 1.2rem;
  flex-wrap: wrap;
}

.summary {
  color: var(--muted);
  font-size: 0.95rem;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border: 1px solid var(--primary);
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}

.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.primary { background: var(--primary); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary); color: white; }
.btn.small { padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #8f3625; border-color: #8f3625; }

.zone {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.zone-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.zone-head h2 {
  font-size: 1.25rem;
  color: var(--primary-dark);
}

.zone-title-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
}
.zone-title-link:hover { border-bottom-color: var(--primary); }

.zone-actions { display: flex; gap: 0.4rem; }

.zone-notes {
  color: var(--muted);
  margin: 0.5rem 0 0.8rem;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.plants { list-style: none; padding: 0; margin: 0.5rem 0 0; }

.plant {
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}

.plant:first-child { border-top: none; padding-top: 0.3rem; }

.plant-main strong { font-size: 1.05rem; }

.variety, .quantity {
  color: var(--muted);
  font-weight: normal;
  margin-left: 0.3rem;
}

.plant-notes {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
  white-space: pre-wrap;
}

.plant-actions {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}

.link.danger { color: var(--danger); }
.inline { display: inline; }

form label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 500;
}

form input[type="text"], form textarea, form select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  color: var(--text);
}

form textarea { resize: vertical; }

.form-row {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.form-row > label {
  flex: 0 0 auto;
  min-width: 160px;
  margin-bottom: 0;
}
.form-row > label.grow { flex: 1 1 200px; }
.form-row > label input[type="text"],
.form-row > label input[type="number"],
.form-row > label select {
  width: 100%;
}

.age-display {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 0.4rem;
}
.age-display .age-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}
/* Catalog hub */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}
.catalog-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.1s;
}
.catalog-card:hover { border-color: var(--primary); }
.catalog-card h2 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 1.1rem;
}
.catalog-count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.4rem 0 0.5rem;
}
.catalog-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

/* Generic entity card list (used by species / varieties / plantings) */
.entity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.6rem;
}
.entity-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.entity-card-link {
  display: block;
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
}
.entity-card-link:hover { background: var(--bg); }
.entity-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.entity-card-header strong { color: var(--primary-dark); font-size: 1.02rem; }
.entity-card-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}
.species-common {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.95rem;
}
.planting-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.planting-meta a {
  color: inherit;
  text-decoration: underline;
}

/* Catalog link fieldset on plant form */
.catalog-link-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1.1rem;
  margin: 0 0 1rem;
  background: var(--bg);
}
.catalog-link-fieldset legend {
  padding: 0 0.4rem;
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 0.95rem;
}
.catalog-link-fieldset .meta {
  margin: 0 0 0.7rem;
}

/* Progress card */
.progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin: 0 0 1.2rem;
}
.progress-card h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0 0 0.7rem;
  font-weight: 600;
}
.progress-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.progress-item {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 0.8rem;
  align-items: center;
}
.progress-label {
  font-size: 0.9rem;
  color: var(--text);
}
.progress-bar {
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s;
}
.progress-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: ui-monospace, Menlo, monospace;
  white-space: nowrap;
}
.progress-count a {
  color: var(--primary);
  text-decoration: none;
  font-family: inherit;
  margin-left: 0.5rem;
  font-size: 0.85rem;
}
.progress-count a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .progress-item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

/* Chip variants */
.chip-warn {
  background: #f4e4c1;
  color: #7a5e1a;
  border-color: #e8d09c;
}

/* Missing-data filters on inventory */
.missing-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.8rem 0 1.2rem;
}
.missing-label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.chip-link {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  font-size: 0.85rem;
}
.chip-link:hover { border-color: var(--primary); color: var(--primary-dark); }
.chip-link.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Tree toolbar (search + expand/collapse) */
.tree-toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
}
.tree-search-wrap {
  flex: 1 1 240px;
  position: relative;
  display: flex;
  align-items: center;
}
.tree-search-wrap input[type=search] {
  width: 100%;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  background: white;
  color: var(--text);
}
.tree-search-wrap input[type=search]:focus {
  outline: none;
  border-color: var(--primary);
}
#tree-search-clear {
  position: absolute;
  right: 0.6rem;
  font-size: 0.85rem;
}

/* Area picker (searchable combobox) */
.area-picker {
  position: relative;
  display: block;
  width: 100%;
}
.area-picker-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.area-picker-trigger:hover { border-color: var(--primary); }
.area-picker-trigger:focus { outline: none; border-color: var(--primary); }
.area-picker-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.area-picker-arrow {
  color: var(--muted);
  font-size: 0.85rem;
}
.area-picker-popover {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  z-index: 20;
  max-height: 360px;
  display: flex;
  flex-direction: column;
}
.area-picker-search {
  padding: 0.55rem 0.8rem;
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
}
.area-picker-search:focus {
  outline: none;
  background: white;
}
.area-picker-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  max-height: 300px;
}
.area-picker-list li {
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-size: 0.93rem;
  border-top: 1px solid var(--border);
  line-height: 1.3;
}
.area-picker-list li:first-child { border-top: none; }
.area-picker-list li:hover { background: var(--bg); color: var(--primary-dark); }

.age-display .age-value {
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.4rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-top: 0.2rem;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.danger-zone {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.empty.small { font-size: 0.9rem; margin: 0.3rem 0 0; }

.schedule-hint {
  margin-top: 2rem;
  text-align: center;
}

.schedule-hint a {
  color: var(--primary);
  font-weight: 500;
}

.schedule-content {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.schedule-content h1:first-child,
.schedule-content h2:first-child { margin-top: 0; }

.schedule-content h1, .schedule-content h2, .schedule-content h3 {
  color: var(--primary-dark);
}

.schedule-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}

.schedule-content th, .schedule-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
}

.schedule-content th { background: var(--bg); }

.schedule-content code {
  background: var(--bg);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.95em;
}

.schedule-content pre {
  background: var(--bg);
  padding: 0.8rem;
  border-radius: 6px;
  overflow-x: auto;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.meta a { color: var(--primary); }

/* Nav logout */
.nav-logout { margin: 0; padding: 0; }
.nav-link-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0;
}
.nav-link-btn:hover { text-decoration: underline; }

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  margin: 1rem;
}
.login-box h1 {
  text-align: center;
  margin: 0 0 1.5rem;
  color: var(--primary-dark);
}
.login-box .error {
  background: #fde8e3;
  border: 1px solid #e8b5a8;
  color: var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.login-box label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  color: var(--muted);
  margin-bottom: 1.2rem;
}
.login-box label.checkbox input {
  width: auto;
  margin: 0;
}
.btn.block {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.75rem;
  font-size: 1.05rem;
}

/* Tree view */
.tree { margin-top: 0.5rem; }

.tree-node {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  overflow: hidden;
}

.tree-node summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  list-style: none;
}
.tree-node summary::-webkit-details-marker { display: none; }
.tree-node summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.8rem;
  width: 0.9rem;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.tree-node[open] > summary::before {
  transform: rotate(90deg);
}
.tree-node summary:hover {
  background: var(--bg);
}
.tree-node .node-name {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
}
.tree-node .node-name:hover { text-decoration: underline; }
.tree-node .node-meta {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chip {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.tree-body {
  padding: 0 1rem 0.8rem 2rem;
}

.tree-plants {
  list-style: none;
  padding: 0;
  margin: 0.2rem 0 0.6rem;
}
.tree-plants li {
  padding: 0.25rem 0;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.tree-plants .plant-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.tree-plants .plant-link:hover { text-decoration: underline; }

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.5rem 0 1rem;
}
.breadcrumbs a {
  color: var(--primary);
  text-decoration: none;
}
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { margin: 0 0.3rem; color: var(--border); }
.breadcrumbs .current { color: var(--text); font-weight: 500; }

/* Zone detail page */
.zone-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.zone-header h1 {
  margin: 0;
  color: var(--primary-dark);
}
.zone-header-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.zone-detail-notes {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  white-space: pre-wrap;
  color: var(--text);
  margin: 0.8rem 0 1.4rem;
  font-size: 0.95rem;
}

.section { margin: 1.5rem 0; }
.section h2 {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 0.7rem;
  font-weight: 600;
}

.child-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}
.child-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: border-color 0.1s, transform 0.05s;
}
.child-card:hover {
  border-color: var(--primary);
}
.child-card strong {
  color: var(--primary-dark);
  font-size: 1rem;
}
.child-card .meta {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.child-card .note-preview {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  line-height: 1.35;
}

.plant-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.plant-item {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
}
.plant-item:first-child { border-top: none; }
.plant-item-link {
  display: block;
  flex: 1;
  padding: 0.8rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.plant-item-link:hover { background: var(--bg); }
.plant-row-actions {
  display: flex;
  align-items: center;
  padding: 0 0.9rem;
  margin: 0;
}
.plant-item-main strong { color: var(--primary-dark); font-size: 1.02rem; }
.plant-item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

/* Status badges */
.status {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--border);
  color: var(--text);
  white-space: nowrap;
}
.status-not-purchased { background: #e4d4c2; color: #6b4d2a; }
.status-not-planted   { background: #ede0b0; color: #7a5e1a; }
.status-planted       { background: #d4e5b8; color: #3f6522; }
.status-growing       { background: #b8dd9c; color: #2e4f17; }
.status-flowering     { background: #f4c4d6; color: #983256; }
.status-fruiting      { background: #ffcf8e; color: #8a5200; }
.status-harvesting    { background: #ffb347; color: #6b3e00; }
.status-dormant       { background: #d0cec8; color: #555; }
.status-dead          { background: #4a3838; color: #e2b9b2; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  html, body { font-size: 15px; }
  header { padding: 0.7rem 0.8rem; }
  header nav { gap: 0.9rem; flex-wrap: wrap; }
  header .logo { font-size: 1.1rem; margin-right: 0.3rem; }
  main { padding: 0.9rem 0.7rem 3rem; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.05rem; }

  /* Native date/number inputs in iOS zoom on focus unless font >= 16 */
  input[type=text], input[type=password], input[type=number],
  input[type=search], input[type=date], textarea, select {
    font-size: 16px;
  }

  .actions {
    gap: 0.5rem;
  }

  /* Filter bar stacks */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.7rem;
  }
  .filter-bar label { min-width: 0; }
  .filter-bar button, .filter-bar .btn { width: 100%; }

  /* Tree toolbar stacks */
  .tree-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .tree-search-wrap { flex: 1 1 auto; }
  .tree-toolbar .btn { flex: 1; }
  .tree-hint { display: none; }

  /* Tree node body shallower indent */
  ul.area-children:not(.area-tree) { padding-left: 1rem; }
  .tree-body { padding: 0 0.7rem 0.7rem 1.2rem; }
  .tree-node summary { padding: 0.7rem 0.8rem; }
  .tree-node .node-meta { flex-basis: 100%; margin-left: 0; margin-top: 0.3rem; }
  .tree-plants li { font-size: 0.9rem; }

  /* Drag handle bigger touch target */
  .drag-handle {
    width: 2rem;
    height: 2rem;
    font-size: 1.1rem;
  }

  /* Child cards single column */
  .child-grid { grid-template-columns: 1fr; }

  /* Station cards single column */
  .station-list { grid-template-columns: 1fr; }

  /* Area detail header — actions stack */
  .zone-header {
    flex-direction: column;
    align-items: stretch;
  }
  .zone-header-actions {
    justify-content: flex-start;
  }
  .zone-header-actions .btn { flex: 1; text-align: center; }

  /* Form row stacks */
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .form-row > label { margin-bottom: 0.8rem; min-width: 0; }

  /* Inventory table — horizontal scroll instead of breaking layout */
  .inv-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .inv-table { min-width: 620px; }

  /* Plant item — duplicate button stacks below */
  .plant-item {
    flex-direction: column;
    align-items: stretch;
  }
  .plant-row-actions {
    padding: 0 1.1rem 0.6rem;
    justify-content: flex-start;
  }

  /* Area picker popover takes more of the screen */
  .area-picker-popover {
    max-height: 60vh;
  }
  .area-picker-list { max-height: calc(60vh - 44px); }

  /* Login box */
  .login-box { padding: 1.5rem; margin: 0.5rem; }

  /* Comment form — date picker on its own line on mobile */
  .comment-form-row { flex-wrap: wrap; }
  .comment-form-row .btn { flex: 1; min-width: 140px; }
}

/* Large touch areas always */
.btn, .mini-btn, .nav-link-btn {
  min-height: 34px;
}

/* Tree as UL (drag-and-drop structure) */
ul.area-tree, ul.area-children {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.area-children:not(.area-tree) {
  padding-left: 1.5rem;
  margin-top: 0.4rem;
  min-height: 0.4rem;
}
.area-node { margin-bottom: 0.4rem; }
.area-node > details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  color: var(--muted);
  cursor: grab;
  user-select: none;
  border-radius: 4px;
  font-size: 1rem;
  flex-shrink: 0;
}
.drag-handle:hover {
  background: var(--bg);
  color: var(--primary);
}
.drag-handle:active { cursor: grabbing; }

.area-ghost {
  opacity: 0.4;
  background: var(--primary);
}
.area-ghost > details { border-color: var(--primary); }
.area-chosen > details { border-color: var(--primary); }

.tree-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: auto;
}
.handle-example {
  display: inline-block;
  padding: 0 0.3rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* Stations */
.station-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.7rem;
}
.station-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.station-card-link {
  display: block;
  padding: 0.9rem 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.station-card-link:hover { background: var(--bg); }
.station-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.station-card-header strong {
  color: var(--primary-dark);
  font-size: 1.05rem;
}
.station-card-schedule {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.station-inline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.station-chip {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  color: var(--text);
}
.station-chip:hover { border-color: var(--primary); }
.station-chip strong { color: var(--primary-dark); }
.station-chip .station-schedule {
  color: var(--muted);
  font-size: 0.82rem;
}

.station-schedule-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.95rem;
  color: var(--primary-dark);
}

.station-area-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.station-area-list li a {
  display: block;
  padding: 0.5rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 500;
}
.station-area-list li a:hover { border-color: var(--primary); }

.area-checklist {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1.1rem;
  margin: 0 0 1rem;
  background: var(--card);
  max-height: 340px;
  overflow-y: auto;
}
.area-checklist legend {
  padding: 0 0.4rem;
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 0.95rem;
}
.area-checklist label.checkbox {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.3rem 0;
  font-weight: normal;
  margin: 0;
}
.area-checklist label.checkbox input {
  width: auto;
  margin: 0;
}

/* Inventory: filter bar */
.filter-bar {
  display: flex;
  gap: 0.8rem;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin: 1rem 0 1.3rem;
}
.filter-bar label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0;
  gap: 0.25rem;
  min-width: 140px;
  flex: 1 1 140px;
}
.filter-bar select {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.95rem;
  background: white;
  color: var(--text);
  font-family: inherit;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 0;
}

/* Inventory: plant table */
.inv-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.inv-table thead th {
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.inv-table tbody tr {
  cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background 0.08s;
}
.inv-table tbody tr:first-child { border-top: none; }
.inv-table tbody tr:hover { background: var(--bg); }
.inv-table td {
  padding: 0.7rem 1rem;
  vertical-align: middle;
}
.inv-table td.muted { color: var(--muted); }
.inv-table td a {
  color: var(--primary);
  text-decoration: none;
}
.inv-table td a:hover { text-decoration: underline; }
.unassigned {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}
.inv-name-link {
  color: var(--text);
  text-decoration: none;
}
.inv-name-link:hover { text-decoration: underline; }
.inv-name-link strong { color: var(--primary-dark); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions-col { width: 1%; }

.mini-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
}
.mini-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Supplies list */
.supply-category {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 1.2rem 0 0.5rem;
  font-weight: 600;
}
.supply-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.supply-item { border-top: 1px solid var(--border); }
.supply-item:first-child { border-top: none; }
.supply-item-link {
  display: block;
  padding: 0.75rem 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.supply-item-link:hover { background: var(--bg); }
.supply-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.supply-main strong { color: var(--primary-dark); }
.supply-amount {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
}
.supply-notes {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  white-space: pre-wrap;
}

/* Commentary */
.commentary { margin-top: 2rem; }
.comment-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.comment {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
}
.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.comment-date {
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 0.85rem;
  font-family: ui-monospace, Menlo, monospace;
}
.comment-actions {
  display: flex;
  gap: 0.7rem;
  font-size: 0.8rem;
  align-items: center;
}
.comment-body {
  color: var(--text);
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.45;
}

.comment-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
}
.comment-form textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  background: white;
  color: var(--text);
  resize: vertical;
  margin-bottom: 0.5rem;
}
.comment-form-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.comment-form input[type="date"] {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.9rem;
  background: white;
  color: var(--text);
}
.btn.small {
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
}
