:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d7dce5;
  --primary: #14532d;
  --primary-strong: #0f3f22;
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.setup-panel,
.bottom-panel {
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px 14px 16px;
  z-index: 2;
}

.setup-panel {
  border-bottom: 1px solid var(--line);
}

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

h1 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 4px;
}

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

.field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.advanced-panel {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 8px;
}

.advanced-panel summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 9px 11px;
  width: 100%;
}

.file-field input {
  padding-top: 10px;
}

.button-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  font-weight: 750;
  padding: 0 18px;
}

.primary-button:active {
  background: var(--primary-strong);
}

.secondary-button {
  background: #eef2f7;
  color: var(--text);
  font-weight: 700;
  padding: 0 14px;
}

.secondary-button:disabled {
  color: #98a2b3;
}

.icon-button {
  align-items: center;
  background: #eef2f7;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 44px;
  font-size: 24px;
  font-weight: 800;
  justify-content: center;
  width: 44px;
}

.map-section {
  min-height: 0;
  position: relative;
}

.map-canvas {
  height: 100%;
  min-height: 320px;
  width: 100%;
}

.status-bar {
  background: rgba(15, 23, 42, 0.88);
  border-radius: 8px;
  bottom: 12px;
  color: #fff;
  font-size: 13px;
  left: 12px;
  line-height: 1.4;
  max-width: calc(100% - 24px);
  padding: 9px 11px;
  position: absolute;
  z-index: 1;
}

.bottom-panel {
  border-top: 1px solid var(--line);
  max-height: 34dvh;
  overflow: auto;
}

.stats-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-grid div {
  background: #f2f5f9;
  border-radius: 8px;
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 8px;
  place-items: center;
  text-align: center;
}

.stats-grid strong {
  font-size: 20px;
  line-height: 1;
}

.stats-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.failure-panel {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
}

.failure-panel summary {
  color: var(--danger);
  font-size: 14px;
  font-weight: 750;
}

.failure-panel ol {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  margin: 10px 0 0;
  padding-left: 24px;
}

.failure-panel li + li {
  margin-top: 8px;
}

.marker-popup {
  color: #172033;
  font-size: 13px;
  line-height: 1.45;
  min-width: 220px;
  max-width: 280px;
  padding: 2px;
}

.marker-popup strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.marker-popup dl {
  display: grid;
  gap: 4px;
  grid-template-columns: 42px minmax(0, 1fr);
  margin: 0 0 10px;
}

.marker-popup dt {
  color: #667085;
  font-weight: 700;
}

.marker-popup dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.remove-marker-button {
  background: var(--danger);
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 750;
  min-height: 38px;
  width: 100%;
}

@media (orientation: landscape) and (max-height: 560px) {
  .app-shell {
    grid-template-columns: 330px minmax(360px, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .setup-panel {
    border-bottom: 0;
    border-right: 1px solid var(--line);
    grid-row: 1 / 3;
    overflow: auto;
  }

  .bottom-panel {
    max-height: 160px;
  }
}
