:root {
  --bg: #f5f4ef;
  --panel: #ffffff;
  --text: #17201b;
  --muted: #617066;
  --line: #d8ded6;
  --green: #2f7d52;
  --green-dark: #1f5f3d;
  --amber: #c18422;
  --red: #ba4638;
  --blue: #285f9f;
  --violet: #7253a4;
  --cyan: #1f8a9b;
  --shadow: 0 22px 60px rgba(23, 32, 27, 0.16);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

#app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  height: 100vh;
  min-height: 620px;
}

.panel {
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel-header,
.section-title,
.toolbar,
.stats,
.legend,
.details > div,
.task-panel {
  display: flex;
  align-items: center;
}

.panel-header,
.section-title {
  justify-content: space-between;
  gap: 14px;
}

.eyebrow,
.status-label,
.small-text {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.eyebrow,
.status-label {
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 760;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 2px 0 0;
  font-size: 30px;
  line-height: 1.04;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.18;
}

h3 {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.2;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats div {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf7;
}

.stats strong,
.stats span {
  display: block;
}

.stats strong {
  font-size: 23px;
  line-height: 1;
}

.stats span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  gap: 8px;
}

.tool-button,
.icon-button,
.submit-button,
.map-control {
  border: 0;
  border-radius: 8px;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 42px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  font-weight: 740;
}

.tool-button.primary {
  flex: 1 1 auto;
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.tool-button.danger {
  color: var(--red);
}

.tool-button:hover,
.icon-button:hover,
.submit-button:hover,
.map-control:hover {
  transform: translateY(-1px);
}

.tool-button:focus-visible,
.icon-button:focus-visible,
.submit-button:focus-visible,
.map-control:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(40, 95, 159, 0.24);
  outline-offset: 2px;
}

.action-status,
.empty-state,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf7;
}

.action-status {
  padding: 11px 13px;
  border-color: #b7d3c2;
  background: #edf8f0;
  color: var(--green-dark);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 720;
}

.finder,
.task-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf7;
}

.finder {
  display: grid;
  gap: 12px;
  padding: 13px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-chip {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #cdd5cc;
  border-radius: 999px;
  background: #ffffff;
  color: #314036;
  font-size: 12px;
  font-weight: 760;
}

.filter-chip.active {
  border-color: var(--green);
  background: #edf8f0;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px rgba(47, 125, 82, 0.18);
}

.sort-control {
  margin: 0;
}

.result-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.task-panel {
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
}

.task-panel strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.2;
}

.compact-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 11px;
  font-size: 13px;
}

.compact-button:disabled {
  cursor: not-allowed;
  background: #9aa49d;
}

.empty-state {
  padding: 15px;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.card {
  padding: 15px;
}

.compact {
  margin-bottom: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  background: #eef1ed;
  color: var(--text);
  font-size: 21px;
  line-height: 1;
}

form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #314036;
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #cdd5cc;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.quantity-input {
  width: 88px;
  text-align: right;
  font-weight: 760;
}

.watering-form {
  grid-template-columns: auto 1fr;
  align-items: end;
  column-gap: 12px;
}

.watering-form label,
.watering-form .submit-button {
  grid-column: 1 / -1;
}

.watering-form label:first-child {
  grid-column: 1;
  width: max-content;
}

.watering-form .locked-date {
  grid-column: 2;
}

.watering-form .submit-button {
  margin-top: 2px;
}

.locked-date {
  display: grid;
  gap: 6px;
  min-height: 42px;
  padding: 0 0 1px;
  color: #314036;
  font-size: 13px;
  font-weight: 700;
}

.locked-date span {
  color: #314036;
}

.locked-date strong {
  align-self: end;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1ed;
  color: var(--muted);
  font-size: 13px;
}

.submit-button {
  min-height: 44px;
  padding: 11px 14px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 780;
}

.secondary-button {
  background: #4b5f53;
}

.danger-button {
  background: var(--red);
}

.details {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
}

.details > div {
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

dd {
  margin: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 760;
}

.history-block {
  margin-top: 16px;
}

.report-form {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.history-list,
.tree-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.history-list li,
.tree-list button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  font-size: 13px;
}

.tree-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 11px 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 10px;
  text-align: left;
}

.tree-list button.selected {
  border-color: rgba(40, 95, 159, 0.72);
  background: #f0f6ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.tree-id {
  display: inline-block;
  margin-right: 4px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 820;
}

.empty-list {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.tree-list strong,
.tree-list span {
  min-width: 0;
}

.tree-list strong {
  font-size: 13px;
}

.tree-list span {
  color: var(--muted);
  font-size: 12px;
}

.tree-list small {
  color: var(--muted);
  font-size: 12px;
}

.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #e1e7dc;
}

.adding-tree #map {
  cursor: crosshair;
}

.adding-tree .toolbar,
.adding-tree .stats,
.adding-tree .finder,
.adding-tree .task-panel,
.adding-tree .empty-state,
.adding-tree .tree-list-block,
.tree-selected .toolbar,
.tree-selected .stats,
.tree-selected .finder,
.tree-selected .task-panel,
.tree-selected .empty-state,
.tree-selected .tree-list-block {
  display: none;
}

.map-actions {
  position: absolute;
  z-index: 460;
  top: 18px;
  right: 18px;
  display: none;
  gap: 8px;
  justify-items: end;
}

.map-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(216, 222, 214, 0.92);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 0 12px 30px rgba(23, 32, 27, 0.18);
  font-size: 24px;
  line-height: 1;
  font-weight: 860;
}

.map-toggle {
  gap: 7px;
  width: auto;
  min-width: 78px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 13px;
}

.map-toggle-icon {
  font-size: 18px;
  line-height: 1;
}

.map-toggle-label {
  font-size: 13px;
  font-weight: 820;
}

.map-control.primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.map-control.active {
  background: var(--amber);
  border-color: var(--amber);
  color: #ffffff;
}

.map-hint,
.legend {
  position: absolute;
  z-index: 450;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(216, 222, 214, 0.9);
  box-shadow: 0 14px 36px rgba(23, 32, 27, 0.12);
}

.map-hint {
  top: 18px;
  right: 18px;
  padding: 11px 13px;
  color: var(--green-dark);
  font-weight: 780;
}

.legend {
  left: 18px;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: min(520px, calc(100% - 36px));
  padding: 10px 12px;
  color: #314036;
  font-size: 12px;
  font-weight: 720;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9aa49d;
}

.dot.fresh,
.tree-marker.fresh,
.tree-list .fresh {
  background: var(--green);
}

.dot.soon,
.tree-marker.soon,
.tree-list .soon {
  background: var(--amber);
}

.dot.dry,
.tree-marker.dry,
.tree-list .dry {
  background: var(--red);
}

.dot.unknown,
.tree-marker.unknown,
.tree-list .unknown {
  background: #7b8580;
}

.tree-marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(23, 32, 27, 0.26);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    outline-color 120ms ease;
}

.leaflet-marker-icon:hover .tree-marker,
.leaflet-lite-marker:hover .tree-marker,
.leaflet-marker-icon:focus-visible .tree-marker,
.leaflet-lite-marker:focus-visible .tree-marker {
  transform: scale(1.22);
  outline: 5px solid rgba(40, 95, 159, 0.28);
  box-shadow: 0 12px 30px rgba(23, 32, 27, 0.36);
}

.tree-marker.selected {
  outline: 4px solid rgba(40, 95, 159, 0.32);
}

.tree-marker.pending {
  width: 32px;
  height: 32px;
  background: var(--blue);
  border-width: 4px;
  outline: 5px solid rgba(40, 95, 159, 0.28);
  box-shadow:
    0 10px 28px rgba(23, 32, 27, 0.34),
    0 0 0 10px rgba(40, 95, 159, 0.16);
}

.tree-marker.pending::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.cluster-marker {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(23, 32, 27, 0.32);
  font-size: 14px;
  font-weight: 840;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.leaflet-marker-icon:hover .cluster-marker,
.leaflet-lite-marker:hover .cluster-marker,
.leaflet-marker-icon:focus-visible .cluster-marker,
.leaflet-lite-marker:focus-visible .cluster-marker {
  transform: scale(1.14);
  background: #1e4f85;
  box-shadow:
    0 14px 34px rgba(23, 32, 27, 0.38),
    0 0 0 8px rgba(40, 95, 159, 0.18);
}

.leaflet-container {
  font-family: inherit;
}

.admin-page {
  min-height: 100%;
  background: #f5f4ef;
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.admin-header,
.admin-auth,
.admin-actions,
.admin-list-item,
.admin-tree-button {
  display: flex;
  align-items: center;
}

.admin-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--blue);
  font-weight: 780;
  text-decoration: none;
}

.admin-auth {
  flex-wrap: wrap;
  gap: 10px;
}

.admin-auth label {
  flex: 1 1 280px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1fr) minmax(320px, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.admin-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.admin-list-item {
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.admin-list-item div,
.admin-report-actions,
.admin-tree-button {
  min-width: 0;
}

.admin-list-item strong,
.admin-list-item span,
.admin-list-item small,
.admin-tree-button strong,
.admin-tree-button span,
.admin-tree-button small {
  display: block;
  overflow-wrap: anywhere;
}

.admin-list-item span,
.admin-list-item small,
.admin-tree-button span,
.admin-tree-button small {
  color: var(--muted);
  font-size: 12px;
}

.admin-report-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.muted-item {
  opacity: 0.68;
}

.admin-tree-button {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.admin-tree-button.selected {
  border-color: rgba(40, 95, 159, 0.72);
  background: #f0f6ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.admin-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions .submit-button {
  flex: 1 1 120px;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  #app-shell {
    display: block;
    min-height: 100vh;
  }

  .map-wrap {
    position: fixed;
    inset: 0;
  }

  .panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    max-height: 58vh;
    padding: 14px;
    border: 1px solid rgba(216, 222, 214, 0.9);
    border-radius: 8px;
    transition: transform 180ms ease;
  }

  .map-focus .panel {
    transform: translateY(calc(100% - 58px));
  }

  .panel-header {
    align-items: flex-start;
  }

  h1 {
    font-size: 25px;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats div {
    padding: 9px 8px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar {
    display: none;
  }

  .tool-button {
    min-height: 40px;
  }

  .map-actions {
    display: grid;
    top: 10px;
    right: 10px;
  }

  .map-control {
    width: 48px;
    height: 48px;
  }

  .map-toggle {
    width: auto;
    min-width: 86px;
  }

  .legend {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(58vh + 22px);
    max-width: none;
  }

  .map-focus .legend {
    bottom: 78px;
  }

  .map-hint {
    left: 10px;
    right: 10px;
    top: 70px;
    text-align: center;
  }

  .admin-shell {
    width: min(100% - 20px, 760px);
    padding: 14px 0;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .panel {
    max-height: 64vh;
  }

  .legend {
    bottom: calc(64vh + 22px);
  }

  .map-focus .legend {
    bottom: 78px;
  }

  .stats strong {
    font-size: 20px;
  }

  .tool-button.primary span:last-child {
    display: none;
  }
}
