:root {
  color-scheme: light;
  --ink: #1b2430;
  --muted: #687385;
  --line: #d8dee8;
  --panel: #f7f9fc;
  --paper: #ffffff;
  --green: #148a5b;
  --green-dark: #0e6745;
  --amber: #c77a16;
  --red: #c7463a;
  --blue: #2563a6;
  --shadow: 0 16px 42px rgba(31, 41, 55, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #eef2f7;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  transition:
    transform 0.14s ease,
    background 0.14s ease,
    box-shadow 0.14s ease;
}

button:hover {
  background: var(--green-dark);
  box-shadow: 0 8px 18px rgba(20, 138, 91, 0.22);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: #30445f;
}

button.secondary:hover {
  background: #213348;
  box-shadow: 0 8px 18px rgba(48, 68, 95, 0.2);
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 166, 0.12);
}

label {
  display: block;
  margin: 11px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) 1fr;
  min-height: 100vh;
}

.panel {
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  overflow: auto;
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 8px;
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand h1 {
  margin-top: 3px;
  font-size: 28px;
  letter-spacing: 0;
}

.sync-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(20, 138, 91, 0.25);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green-dark);
  background: rgba(20, 138, 91, 0.09);
  font-size: 12px;
  font-weight: 800;
}

.section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 16px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 8px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.result-box {
  margin-top: 10px;
  min-height: 54px;
  border-radius: 8px;
  padding: 10px;
  color: #405066;
  background: #f3f6fa;
  font-size: 13px;
  line-height: 1.5;
}

.radius-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: #e9edf4;
}

.radius-tabs button {
  min-height: 34px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.radius-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.nearby-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  margin-top: 10px;
  overflow: auto;
}

.nearby-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.nearby-item strong {
  display: block;
  font-size: 14px;
}

.nearby-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

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

.map-toolbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: none;
}

.metric {
  min-width: 126px;
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(31, 41, 55, 0.12);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.container-marker {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid #fff;
  border-radius: 10px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 20px rgba(24, 35, 49, 0.24);
  font-weight: 900;
}

.container-marker.low {
  background: var(--amber);
}

.container-marker.empty {
  background: var(--red);
}

.delivery-marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(24, 35, 49, 0.22);
  font-size: 13px;
  font-weight: 900;
}

.leaflet-popup-content {
  min-width: 210px;
}

.popup-title {
  margin: 0 0 7px;
  font-weight: 900;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 5px;
  color: #405066;
  font-size: 13px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #map {
    height: 64vh;
    min-height: 480px;
  }
}

@media (max-width: 520px) {
  .panel {
    padding: 14px;
  }

  .brand {
    align-items: stretch;
    flex-direction: column;
  }

  .field-row,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .map-toolbar {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .metric {
    flex: 1 1 120px;
    min-width: 0;
  }
}
