:root {
  --text: #1f2527;
  --muted: #5f6a6d;
  --line: #cfd3d4;
  --line-strong: #aeb4b6;
  --surface: rgba(248, 248, 247, 0.94);
  --surface-solid: #f2f2f0;
  --primary: #cf3f35;
  --danger: #9c2d26;
  --shadow: 0 10px 28px rgba(30, 37, 39, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.topbar {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 850;
  border-radius: 12px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.topbar-left input {
  width: min(460px, 50vw);
  min-width: 180px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  padding: 7px 10px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--text);
  padding: 7px 12px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: #b5342c;
}

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

button.action-find {
  border-color: #cf3f35;
  background: #cf3f35;
  color: #fff;
}

button.action-find:hover:not(:disabled) {
  background: #b3342c;
  border-color: #b3342c;
}

button.action-fulfill {
  border-color: #2f9b56;
  background: #2f9b56;
  color: #fff;
}

button.action-fulfill:hover:not(:disabled) {
  background: #257b44;
  border-color: #257b44;
}

.bottombar {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 850;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-radius: 12px;
  padding: 8px;
}

.floating-panel {
  position: fixed;
  z-index: 860;
  width: min(380px, calc(100vw - 20px));
  max-height: min(72vh, 650px);
  overflow: auto;
  border-radius: 12px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

#addressesPanel {
  top: 64px;
  right: 10px;
}

#optionsPanel {
  top: 64px;
  right: 10px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.close-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}

.summary {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.address-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.84);
}

.address-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  cursor: pointer;
}

.address-item:last-child {
  border-bottom: 0;
}

.address-item:hover {
  background: rgba(255, 255, 255, 1);
}

.address-item.selected {
  background: #eef5f7;
}

.address-item.start {
  background: #fff9cf;
}

.address-item.end {
  border-left: 3px solid var(--primary);
}

.address-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #111;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 0.7rem;
  font-weight: 700;
}

.address-icon.start {
  background: #ffe600;
  color: #111;
}

.address-icon.end {
  background: #cf3f35;
  color: #fff;
}

.address-text {
  font-size: 0.9rem;
  line-height: 1.25;
  min-width: 0;
}

.selection-actions {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  padding: 8px;
}

.selected-address {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.option-note {
  margin: 8px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.metrics {
  position: fixed;
  left: 10px;
  bottom: 70px;
  z-index: 850;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.metrics p {
  margin: 0;
  font-size: 0.88rem;
}

.status {
  position: fixed;
  left: 10px;
  top: 64px;
  z-index: 850;
  border-radius: 12px;
  padding: 7px 10px;
  margin: 0;
  font-size: 0.86rem;
  max-width: min(720px, calc(100vw - 20px));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 990;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 30, 31, 0.36);
  padding: 12px;
}

.modal-dialog {
  width: min(900px, 100%);
  max-height: min(86vh, 900px);
  border-radius: 14px;
  background: #f4f4f2;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fulfill-dialog {
  width: min(1880px, 100%);
  max-height: min(92vh, 960px);
}

.modal-note {
  margin: 0;
  font-size: 0.95rem;
}

#importTextarea {
  width: 100%;
  min-height: min(58vh, 460px);
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  line-height: 1.35;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.fulfill-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  max-height: calc(min(92vh, 960px) - 90px);
  padding-right: 4px;
}

.fulfill-card {
  border: 1px solid var(--line-strong);
  background: #e8e8e8;
}

.fulfill-card.complete {
  background: #eef4f5;
}

.fulfill-head {
  background: #a6a6a6;
  color: #111;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.fulfill-index {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fulfill-eta {
  color: #fff;
  font-size: 0.92rem;
}

.fulfill-body {
  padding: 10px;
}

.fulfill-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.fulfill-sub {
  margin: 4px 0 0;
  color: #5f5f5f;
  font-size: 0.88rem;
}

.fulfill-actions {
  border-top: 1px solid #cfcfcf;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.fulfill-actions button {
  min-width: 92px;
}

.hidden {
  display: none !important;
}

.map-marker {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.map-marker.start {
  background: #ffe600;
  color: #111;
}

.map-marker.end {
  background: #cf3f35;
}

.map-marker.done {
  opacity: 0.35;
}

.home-icon {
  width: 13px;
  height: 13px;
  display: block;
}

.popup-wrap {
  min-width: 220px;
}

.popup-title {
  margin: 0 0 8px;
  font-size: 0.86rem;
  line-height: 1.3;
}

.popup-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.popup-actions button {
  padding: 4px 8px;
  font-size: 0.8rem;
}

@media (max-width: 800px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 7px;
    gap: 7px;
  }

  .topbar-left input {
    width: 100%;
  }

  .topbar-right {
    justify-content: flex-end;
  }

  .status {
    top: 102px;
  }

  #addressesPanel,
  #optionsPanel {
    top: 100px;
  }

  .metrics {
    left: 10px;
    right: 10px;
    bottom: 84px;
    flex-wrap: wrap;
  }

  .bottombar {
    left: 10px;
    right: 10px;
  }
}
