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

html {
  overflow: hidden;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  color: #16202a;
  background: #eef2f5;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #c7d2dc;
  box-shadow: 0 1px 4px rgba(21, 35, 48, 0.14);
  z-index: 3;
  flex-wrap: wrap;
  min-width: 0;
}

.toolbar__group,
.layer-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.toolbar label,
.layer-row label {
  font-size: 13px;
  font-weight: 700;
}

.toolbar select,
.toolbar button,
.layer-actions input {
  height: 34px;
  border: 1px solid #98a9b6;
  border-radius: 5px;
  background: #ffffff;
  color: #16202a;
  font-size: 14px;
}

.toolbar select {
  min-width: 220px;
  padding: 0 8px;
}

.toolbar button {
  padding: 0 12px;
  cursor: pointer;
}

.toolbar button:hover,
.toolbar select:hover,
.layer-actions input:hover {
  border-color: #315e7e;
}

.toolbar__group--check input {
  width: 18px;
  height: 18px;
}

.toolbar__group--range input {
  width: 130px;
}

.shell {
  display: grid;
  grid-template-columns: 370px 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(140px, 1fr) minmax(120px, 0.45fr);
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
  border-right: 1px solid #c7d2dc;
  z-index: 2;
}

.summary {
  padding: 12px;
  border-bottom: 1px solid #e2e8ee;
}

.summary h1,
.details h2,
.group-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.summary dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  margin: 10px 0 0;
  font-size: 13px;
}

.summary dt {
  color: #556575;
}

.summary dd {
  margin: 0;
  font-weight: 700;
}

.layer-actions {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8ee;
}

.layer-actions input {
  width: 100%;
  padding: 0 9px;
}

.layer-list,
.details {
  overflow: auto;
  min-height: 0;
}

.group {
  border-bottom: 1px solid #e9eef3;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: #f6f8fa;
  color: #22313f;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.group-title::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #526575;
}

.group[data-open="true"] .group-title::after {
  content: "";
  border-top: 0;
  border-bottom: 7px solid #526575;
}

.group-title:hover {
  background: #edf2f6;
}

.group-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e4ebf0;
  color: #4c5e6e;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.group-title:focus {
  outline: 2px solid #8aa8bd;
  outline-offset: -2px;
}

.group-body {
  display: none;
}

.group[data-open="true"] .group-body {
  display: block;
}

.layer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #edf2f6;
}

.layer-row input {
  width: 17px;
  height: 17px;
}

.layer-row small {
  color: #5c6d7b;
  font-size: 12px;
}

.source-badge {
  display: inline-block;
  margin: 4px 5px 0 0;
  padding: 1px 6px;
  border-radius: 4px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}

.source-cheshire { background: #315e7e; }
.source-ons { background: #2c7a62; }
.source-dft { background: #b45f1f; }
.source-ea { background: #1f7294; }
.source-natural { background: #4c7c2f; }
.source-heritage { background: #7b4e94; }
.source-ofcom { background: #8a5d20; }
.source-land { background: #9b3f5a; }
.source-bgs { background: #68733a; }
.source-gov { background: #555f6d; }
.source-other { background: #66727d; }

.count {
  min-width: 26px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef3f6;
  color: #334653;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.details {
  padding: 12px;
  border-top: 1px solid #c7d2dc;
  font-size: 13px;
}

.details p {
  margin: 8px 0 0;
}

.details-intro {
  color: #334653;
  line-height: 1.45;
}

.source-card {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #d6e0e8;
  border-radius: 6px;
  background: #f7fafc;
}

.source-card p {
  margin: 4px 0 6px;
  color: #485b6b;
  line-height: 1.4;
}

.details table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  table-layout: fixed;
}

.details th,
.details td {
  padding: 5px 0;
  border-top: 1px solid #e3e9ee;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

.details th {
  width: 42%;
  color: #556575;
  font-weight: 700;
}

.nested-table {
  max-width: 100%;
  overflow: auto;
}

.nested-table table {
  min-width: 620px;
  table-layout: auto;
}

.nested-table th,
.nested-table td {
  padding: 4px 6px;
  font-size: 11px;
}

.json-value {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.details a {
  color: #0c5d88;
  font-weight: 700;
}

.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#status {
  position: absolute;
  right: 14px;
  bottom: 14px;
  max-width: min(480px, calc(100vw - 28px));
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #c3cfd8;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(21, 35, 48, 0.16);
  z-index: 2;
}

.popup {
  position: absolute;
  transform: translate(-50%, calc(-100% - 10px));
  min-width: 130px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #9bacb8;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(21, 35, 48, 0.22);
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

.popup::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-right: 1px solid #9bacb8;
  border-bottom: 1px solid #9bacb8;
  transform: translateX(-50%) rotate(45deg);
}

.ol-attribution {
  font-size: 11px;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 42vh) minmax(0, 1fr);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #c7d2dc;
  }
}

@media (max-width: 720px) {
  .toolbar {
    align-items: stretch;
  }

  .toolbar__group,
  .toolbar button,
  .toolbar select {
    width: 100%;
  }

  .toolbar__group--check,
  .toolbar__group--range {
    width: auto;
  }
}
