:root {
  --bg-deep: #0e110e;
  --bg-panel: rgba(18, 22, 18, 0.88);
  --bg-panel-solid: #151a15;
  --stroke: rgba(214, 196, 160, 0.14);
  --stroke-strong: rgba(214, 196, 160, 0.28);
  --text: #e8e4d8;
  --text-muted: rgba(232, 228, 216, 0.58);
  --copper: #c47a4a;
  --copper-bright: #e0945e;
  --olive: #6b7c5a;
  --olive-soft: rgba(107, 124, 90, 0.35);
  --danger: #c45a4a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font-display: "Syne", "Avenir Next", sans-serif;
  --font-body: "Manrope", "Avenir Next", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #1a1f1a;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Brand — hero-level, not nav chrome */
.brand-bar {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  animation: brandIn 0.9s var(--ease) both;
}

.brand-mark {
  color: var(--copper-bright);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 0.95;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.65rem, 3.2vw, 2.15rem);
  letter-spacing: -0.03em;
  color: var(--text);
}

.brand-product {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--copper-bright);
  margin-top: 2px;
}

@keyframes brandIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Panel */
.panel {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  width: min(380px, calc(100vw - 40px));
  padding: 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: panelIn 0.85s var(--ease) 0.08s both;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.search-wrap {
  position: relative;
}

#search-input {
  width: 100%;
  height: 48px;
  padding: 0 42px 0 16px;
  border: 1px solid var(--stroke-strong);
  border-radius: 12px;
  background: rgba(8, 10, 8, 0.55);
  color: var(--text);
  font: 500 0.95rem/1.2 var(--font-body);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input:focus {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(196, 122, 74, 0.2);
}

.icon-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  max-height: 260px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--bg-panel-solid);
}

.search-results li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text);
  transition: background 0.15s ease;
}

.search-results li:hover,
.search-results li[aria-selected="true"] {
  background: var(--olive-soft);
}

.search-results .muted {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.route-mode {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--stroke);
}

.route-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
}

.route-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  justify-self: center;
}

.route-dot.start {
  background: var(--olive);
  box-shadow: 0 0 0 3px rgba(107, 124, 90, 0.35);
}

.route-dot.end {
  background: var(--copper);
  box-shadow: 0 0 0 3px rgba(196, 122, 74, 0.35);
}

.route-row input {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: rgba(8, 10, 8, 0.4);
  color: var(--text);
  font: 500 0.82rem/1.2 var(--font-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
}

.route-row input:focus {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(196, 122, 74, 0.2);
}

.route-suggest {
  margin: 0 0 4px 24px;
  max-height: 180px;
}

.text-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  border: 1px solid var(--stroke-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: 700 0.8rem/1 var(--font-display);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.text-btn:hover,
.text-btn.active {
  border-color: var(--copper);
  color: var(--copper-bright);
  background: rgba(196, 122, 74, 0.12);
}

.text-btn.danger {
  color: var(--danger);
  border-color: rgba(196, 90, 74, 0.35);
}

.route-meta {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  animation: metaIn 0.45s var(--ease) both;
}

@keyframes metaIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.meta-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.meta-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--copper-bright);
}

.hint {
  margin: 12px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Toolbar */
.toolbar {
  position: absolute;
  right: 20px;
  bottom: 28px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: panelIn 0.85s var(--ease) 0.16s both;
}

.tool-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  color: var(--text);
  font: 600 1.25rem/1 var(--font-body);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tool-btn:hover {
  transform: translateY(-1px);
  border-color: var(--copper);
  color: var(--copper-bright);
}

.tool-btn[aria-pressed="true"] {
  border-color: var(--olive);
  color: #b8c7a8;
}

/* Toast & context */
.toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 1100;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--stroke-strong);
  background: var(--bg-panel-solid);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  animation: metaIn 0.35s var(--ease) both;
}

.context-card {
  position: absolute;
  z-index: 1100;
  width: min(300px, calc(100vw - 32px));
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke-strong);
  background: var(--bg-panel-solid);
  box-shadow: var(--shadow);
  animation: metaIn 0.3s var(--ease) both;
}

.context-addr {
  margin: 0 0 10px;
  font-size: 0.86rem;
  line-height: 1.4;
}

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

.chip {
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: 600 0.75rem/1 var(--font-body);
  cursor: pointer;
}

.chip:hover {
  border-color: var(--copper);
  color: var(--copper-bright);
}

.chip.ghost {
  color: var(--text-muted);
}

.map-credit {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 1000;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.map-credit a {
  color: inherit;
  pointer-events: auto;
  text-decoration: none;
}

.map-credit a:hover {
  color: var(--copper-bright);
}

.fleet-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--stroke);
}

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

.fleet-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.fleet-live {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--olive);
}

.fleet-legend {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.fleet-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.leg-dot.device {
  background: #4c8dff;
  box-shadow: 0 0 0 2px rgba(47, 111, 237, 0.35);
}

.leg-dot.courier {
  background: var(--olive);
}

.leg-dot.dest {
  background: var(--copper-bright);
}

#btn-fleet[aria-pressed="true"] {
  color: #4c8dff;
  border-color: rgba(76, 141, 255, 0.45);
}

/* Leaflet overrides */
.leaflet-container {
  font-family: var(--font-body);
  background: #1a1f1a;
}

.leaflet-control-attribution {
  display: none;
}

.leaflet-control-zoom {
  display: none;
}

.emare-marker {
  background: transparent !important;
  border: 0 !important;
  width: 28px !important;
  height: 28px !important;
}

.emare-pin {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(18, 22, 18, 0.85);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  /* Zoom ile büyümez — ekran pikseli sabit; animasyon sadece ilk görünüş */
  animation: pinAppear 0.45s var(--ease) both;
  transform-origin: center center;
}

.emare-pin.start {
  background: var(--olive);
}

.emare-pin.end {
  background: var(--copper);
}

.emare-pin.place {
  background: var(--copper-bright);
}

.emare-pin.me {
  background: #7c5cff;
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.28), 0 6px 16px rgba(0, 0, 0, 0.4);
}

@keyframes pinAppear {
  0% {
    opacity: 0;
    transform: rotate(-45deg) scale(0.85);
  }
  100% {
    opacity: 1;
    transform: rotate(-45deg) scale(1);
  }
}

.route-line {
  filter: drop-shadow(0 0 4px rgba(196, 122, 74, 0.45));
}

/* Quiet layer: desaturate tiles slightly via CSS filter on map pane */
.map-quiet .leaflet-tile-pane {
  filter: saturate(0.55) contrast(1.05) brightness(0.92);
}

@media (max-width: 720px) {
  .brand-bar {
    top: 12px;
    left: 12px;
  }

  .brand-name {
    font-size: 1.45rem;
  }

  .panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 46vh;
    overflow: auto;
  }

  .toolbar {
    right: 12px;
    bottom: calc(46vh + 12px);
  }

  .toast {
    bottom: calc(46vh + 16px);
  }
}
