:root {
  --panel: #ffffff;
  --panel-muted: #f1eee7;
  --text: #22211d;
  --muted: #6d685f;
  --border: #d8d3c7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --focus: rgba(15, 118, 110, 0.2);
  --shadow: 0 10px 28px rgba(34, 33, 29, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
.map-area,
#viewDiv {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #ece8df;
  color: var(--text);
  font-family: "Aptos", "Tahoma", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell,
.map-area {
  position: relative;
}

.map-search {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  left: 12px;
  z-index: 4;
}

.search-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  direction: rtl;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.map-search input,
.map-search button {
  box-shadow: var(--shadow);
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 8px 13px;
  transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

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

.icon-button,
.secondary-button {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
}

.icon-button:hover,
.secondary-button:hover {
  border-color: #bcb5a7;
  background: var(--panel-muted);
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  width: min(88vw, 380px);
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: max(18px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.panel.is-open {
  transform: translateX(0);
}

.panel-backdrop {
  position: fixed;
  top: 0;
  right: min(88vw, 380px);
  bottom: 0;
  left: 0;
  z-index: 5;
  display: none;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: rgba(34, 33, 29, 0.34);
  padding: 0;
}

.panel-backdrop.is-open {
  display: block;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

h1 {
  margin: 0 0 5px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

label {
  display: block;
  margin-bottom: 7px;
  color: #3f3b35;
  font-size: 13px;
  font-weight: 700;
}

.filters-section,
.actions-section {
  display: grid;
  gap: 12px;
}

.summary-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-muted);
}

.summary-section div {
  min-width: 0;
  padding: 12px;
}

.summary-section div + div {
  border-right: 1px solid var(--border);
}

.summary-section span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.summary-section strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 20px;
}

.results-list {
  display: none;
  max-height: min(310px, calc(100vh - 84px));
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.results-list.is-open {
  display: block;
}

.result-item {
  width: 100%;
  min-height: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  text-align: right;
  box-shadow: none;
}

.result-item:hover,
.result-item:focus {
  background: var(--panel-muted);
  color: var(--text);
}

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

.result-main {
  display: block;
  font-weight: 700;
}

.result-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.map-status {
  position: absolute;
  left: 12px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 82px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  display: none;
  font-size: 13px;
  padding: 10px 12px;
  z-index: 4;
}

.map-status.is-visible {
  display: block;
}

.map-status.is-error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.location-fab {
  position: absolute;
  right: 12px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  padding: 0;
}

.location-icon {
  display: block;
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.location-icon-body {
  fill: #fff;
}

.location-icon-dot {
  fill: var(--accent);
}

.esri-ui {
  direction: ltr;
}

.esri-ui-top-left,
.esri-ui-top-right {
  top: 70px;
}

.esri-ui-bottom-left,
.esri-ui-bottom-right {
  bottom: 84px;
}

@media (min-width: 760px) {
  .map-search {
    right: 18px;
    left: auto;
    width: min(520px, calc(100vw - 36px));
  }

  .map-status {
    left: 18px;
  }

  .location-fab {
    right: 18px;
  }
}
