:root {
  --sidebar-bg: #101a31;
  --sidebar-bg-2: #0c1428;
  --card-bg: rgba(20, 31, 57, 0.92);
  --card-bg-strong: rgba(16, 27, 51, 0.98);
  --input-bg: #10182d;
  --input-bg-focus: #0e172c;
  --line: rgba(139, 162, 204, 0.22);
  --line-strong: rgba(166, 187, 226, 0.32);
  --text: #f7f9ff;
  --text-soft: #c9d6f6;
  --muted: #8ea4d6;
  --blue: #4d7ed8;
  --blue-2: #2f5aa8;
  --blue-soft: rgba(93, 138, 222, 0.20);
  --green: #9bd674;
  --green-bg: rgba(126, 206, 98, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
  --radius-lg: 18px;
  --radius-md: 13px;
  --sidebar-width: 424px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: #0b1020;
  color: var(--text);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: 100vw;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  padding: 20px 20px 18px;
  background:
    radial-gradient(circle at 18% 0%, rgba(57, 89, 157, 0.18), transparent 32%),
    linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  border-right: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: var(--shadow);
}

.brand {
  padding: 0 2px 16px;
}

.brand h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--text);
}

.brand p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.35;
  color: #8fb5ff;
}

.control-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 16px 16px;
  background: linear-gradient(180deg, rgba(22, 34, 63, 0.95), rgba(16, 27, 51, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 14px 36px rgba(0, 0, 0, 0.18);
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
}

.field-search {
  margin-bottom: 18px;
}

.searchbox {
  position: relative;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: #8da0c8;
  pointer-events: none;
}

input,
select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input {
  padding: 0 14px 0 44px;
}

input::placeholder {
  color: #7d8fb8;
}

select {
  padding: 0 42px 0 14px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #dfe7ff 50%),
    linear-gradient(135deg, #dfe7ff 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 21px,
    calc(100% - 12px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus {
  border-color: rgba(122, 164, 248, 0.70);
  background-color: var(--input-bg-focus);
  box-shadow: 0 0 0 4px rgba(77, 126, 216, 0.18);
}

.filter-row,
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.maptype-row {
  margin-top: 14px;
}

.button-row {
  margin-top: 16px;
}

.btn {
  min-height: 45px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  transition: transform 150ms ease, filter 150ms ease, border-color 150ms ease, background 150ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(180deg, var(--blue), var(--blue-2));
  border-color: rgba(141, 178, 255, 0.25);
  box-shadow: 0 10px 20px rgba(45, 92, 175, 0.24);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line-strong);
}

.result-count {
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--text-soft);
}

.result-count strong {
  color: #9bbcff;
  font-weight: 800;
}

.hint {
  margin: 8px 0 0;
  color: #b6c3e4;
  font-size: 13px;
}

.farm-list-card {
  min-height: 0;
  flex: 1;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(14, 24, 47, 0.82);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.list {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: auto;
  scrollbar-color: rgba(255, 255, 255, 0.72) rgba(255, 255, 255, 0.12);
}

.list::-webkit-scrollbar { width: 14px; }
.list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.12); }
.list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  border: 3px solid rgba(14, 24, 47, 0.82);
}

.item {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid rgba(145, 167, 205, 0.16);
  background: transparent;
  color: var(--text);
  padding: 16px 20px;
  cursor: pointer;
}

.item:hover,
.item:focus-visible {
  outline: none;
  background: rgba(96, 134, 218, 0.13);
}

.item.is-active {
  background: rgba(72, 118, 210, 0.20);
  box-shadow: inset 3px 0 0 #6e9cff;
}

.item .name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.item .loc {
  color: #91aff1;
  font-size: 13px;
  line-height: 1.35;
}

.item .meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin-top: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.pill-blue {
  color: #a9c6ff;
  border: 1px solid rgba(104, 154, 255, 0.38);
  background: rgba(42, 92, 181, 0.20);
}

.pill-green {
  color: #c8f3aa;
  border: 1px solid rgba(149, 222, 113, 0.42);
  background: var(--green-bg);
}

.map-panel {
  position: relative;
  min-width: 0;
  height: 100vh;
  background: #0b1020;
}

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

/* Google Maps popup content */
.google-popup {
  min-width: 282px;
  max-width: 350px;
  font-family: Inter, Arial, Helvetica, sans-serif;
  color: #172037;
}

.google-popup h2 {
  margin: 0 0 8px;
  color: #0f1a31;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.google-popup p {
  margin: 0 0 10px;
  color: #4a5876;
  font-size: 13px;
  line-height: 1.45;
}

.google-popup strong {
  color: #1e2a44;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.popup-grid div {
  border: 1px solid #dfe6f4;
  border-radius: 12px;
  padding: 9px 10px;
  background: #f7f9fd;
}

.popup-grid strong {
  display: block;
  margin-bottom: 4px;
  color: #6a7894;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.popup-grid span {
  display: block;
  color: #101a31;
  font-size: 14px;
  font-weight: 800;
}

.coords {
  color: #647391 !important;
  font-size: 12px !important;
}

.maps-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 13px;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(180deg, var(--blue), var(--blue-2));
  font-size: 13px;
  font-weight: 800;
}

.map-message {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(54, 87, 160, 0.34), transparent 34%),
    linear-gradient(180deg, #111a31, #0a1020);
  color: var(--text);
}

.map-message h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.map-message p {
  max-width: 560px;
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
}

.empty-list {
  padding: 20px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.45;
}

@media (max-width: 960px) {
  body { overflow: auto; }
  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }
  .sidebar {
    height: auto;
    max-height: none;
    min-height: 46vh;
    padding: 18px;
  }
  .farm-list-card {
    max-height: 42vh;
  }
  .map-panel,
  #map {
    height: 54vh;
  }
}

@media (max-width: 560px) {
  .filter-row,
  .button-row {
    grid-template-columns: 1fr;
  }
  .brand h1 {
    font-size: 22px;
  }
  .control-card {
    padding: 15px;
  }
}
