html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  background: linear-gradient(180deg, #f2f8eb 0%, #e6f4dc 100%);
  color: #1f3b21;
}

.navbar.bg-white {
  background: linear-gradient(90deg, #2f6f3e 0%, #4e9f58 100%) !important;
  border-color: #3b8548 !important;
}

.navbar .navbar-brand,
.navbar .nav-link,
.navbar .navbar-toggler {
  color: #f7fff4 !important;
}

.footer {
  background: #f7fff4;
  border-color: #cfe8c9 !important;
}

.map-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 0;
  height: calc(100vh - 56px);
  border: 1px solid #b8d9b0;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #f8fdf4 0%, #eaf7e3 100%);
  box-shadow: 0 12px 30px rgba(47, 111, 62, 0.12);
}

.layer-sidebar {
  background: linear-gradient(180deg, #f7fdf2 0%, #e9f7e4 100%);
  border-right: 1px solid #cfe6c8;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.layer-sidebar h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f2937;
}

.layer-sidebar-hint {
  margin: 0.5rem 0 1rem;
  color: #556277;
  font-size: 0.9rem;
}

.semantic-search {
  margin-bottom: 0.8rem;
  margin: 0;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e2e8f0;
}

.semantic-search-label {
  display: block;
  font-size: 0.82rem;
  color: #1f2937;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.semantic-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
}

.semantic-search-input {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
  color: #0f172a !important;
  background: #ffffff !important;
  font-family: inherit;
  font-weight: 400;
}

.semantic-search-input::placeholder {
  color: #94a3b8 !important;
  opacity: 1 !important;
}

.semantic-search-input:focus {
  outline: 2px solid #0f172a;
  outline-offset: 0;
}

.semantic-search-button {
  border: 1px solid #2f6f3e;
  background: linear-gradient(90deg, #2f6f3e 0%, #4e9f58 100%);
  color: #ffffff;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.semantic-search-button:hover {
  background: linear-gradient(90deg, #275f35 0%, #3e8b4b 100%);
}

.timeline-open-link {
  display: inline-block;
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: #0f172a;
  text-decoration: underline;
}

.semantic-answer {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  font-size: 0.84rem;
  margin-bottom: 0.65rem;
  white-space: pre-wrap;
}

.semantic-results {
  border: 1px solid #dbe2ec;
  border-radius: 8px;
  background: #ffffff;
  margin-bottom: 0.65rem;
  overflow: hidden;
}

.semantic-results-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #334155;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid #e5eaf2;
}

.semantic-results ul {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
}

.semantic-result-item {
  border-bottom: 1px solid #edf1f7;
}

.semantic-result-item:last-child {
  border-bottom: 0;
}

.semantic-result-jump {
  width: 100%;
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.45rem 0.55rem;
}

.semantic-result-jump:hover {
  background: #f8fafc;
}

.semantic-result-title {
  font-size: 0.86rem;
  color: #0f172a;
  font-weight: 600;
}

.semantic-result-meta {
  margin-top: 0.1rem;
  font-size: 0.74rem;
  color: #64748b;
}

.location-log-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999 !important;
}

.location-log-modal[hidden] {
  display: none !important;
}

.location-log-backdrop {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(0, 0, 0, 0.5) !important;
  z-index: -1 !important;
}

.location-log-dialog {
  background: #ffffff !important;
  border-radius: 12px !important;
  border: 1px solid #dbe2ec !important;
  padding: 1.2rem !important;
  max-width: 420px !important;
  width: 90% !important;
  max-height: 85vh !important;
  overflow-y: auto !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
  position: relative !important;
  z-index: 10000 !important;
}

.location-log-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.35rem;
}

.location-log-selected {
  font-size: 0.76rem;
  color: #475569;
  margin-bottom: 0.4rem;
}

.location-log-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.location-log-input,
.location-log-textarea,
.location-log-file {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
  background: #ffffff;
  color: #0f172a;
}

.location-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.location-log-close {
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.location-log-close:hover {
  background: #1e293b;
}

.location-log-submit {
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #ffffff;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  flex: 1;
  cursor: pointer;
}

.location-log-submit:hover {
  background: #1e293b;
}

.location-log-button-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.location-log-reset {
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #334155;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}

.location-log-reset:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.location-log-status {
  margin-top: 0.35rem;
  font-size: 0.76rem;
  color: #0f172a;
}

.location-history {
  margin-top: 0.5rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.45rem;
}

.location-history-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #334155;
  margin-bottom: 0.3rem;
}

.location-history-filters {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.history-filter {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
}

.history-filter.active {
  border-color: #0f172a;
  background: #0f172a;
  color: #ffffff;
}

.location-history ul {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 170px;
  overflow-y: auto;
}

.location-history-item {
  border-bottom: 1px solid #edf1f7;
  padding: 0.35rem 0;
}

.location-history-item:last-child {
  border-bottom: 0;
}

.location-history-head {
  font-size: 0.8rem;
  color: #0f172a;
  font-weight: 600;
}

.location-history-type {
  font-size: 0.72rem;
  color: #64748b;
}

.location-history-content,
.location-history-attachment,
.location-history-time {
  font-size: 0.74rem;
  color: #475569;
}

.popup-attrs-table {
  margin-top: 0.4rem;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.popup-attrs-table th,
.popup-attrs-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 0.2rem 0.35rem;
  vertical-align: top;
}

.popup-attrs-table th {
  text-align: left;
  color: #334155;
  width: 42%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.popup-attrs-table td {
  color: #0f172a;
  word-break: break-word;
}

.popup-history {
  margin-top: 0.45rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.35rem;
}

/* ── Leaflet popup shell overrides ────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  box-shadow: 0 6px 24px rgba(15,23,42,0.16) !important;
  border: 1px solid #dbe2ec !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
  min-width: 220px;
}

.leaflet-popup-tip-container {
  margin-top: -1px;
}

/* Scrollable popup body */
.popup-body {
  padding: 0.7rem 0.8rem 0.5rem;
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.popup-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.2rem;
  line-height: 1.35;
}

.popup-category {
  font-size: 0.73rem;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.popup-content-text {
  font-size: 0.78rem;
  color: #334155;
  white-space: pre-wrap;
  margin-bottom: 0.35rem;
  max-height: 90px;
  overflow-y: auto;
  background: #f8fafc;
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
}

.popup-footer {
  border-top: 1px solid #e2e8f0;
  padding: 0.45rem 0.8rem;
  background: #f8fafc;
}

.popup-footer-row {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.popup-footer-row .marker-log-action {
  flex: 1;
  width: auto;
}

.marker-log-action {
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #fff;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: center;
}

.marker-log-action:hover {
  background: #1e293b;
}

.marker-delete-btn {
  border: 1px solid #dc2626;
  background: transparent;
  color: #dc2626;
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.marker-delete-btn:hover {
  background: #fef2f2;
}

.history-item-delete {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0 0.15rem;
  float: right;
  line-height: 1.2;
  font-weight: 700;
}

.history-item-delete:hover {
  color: #dc2626;
}

.popup-history-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.2rem;
}

.popup-history ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.popup-history-item {
  margin-bottom: 0.28rem;
}

.popup-history-text,
.popup-history-link,
.popup-history-time {
  font-size: 0.72rem;
  color: #334155;
}

.popup-history-time {
  color: #64748b;
}

.timeline-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 0.2rem 1.2rem;
}

.timeline-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #f59e0b;
  background: #fff7ed;
  color: #9a3412;
  text-decoration: none;
  font-weight: 700;
  width: fit-content;
}

.timeline-back-link:hover {
  background: #ffedd5;
  color: #7c2d12;
}

.timeline-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #0f172a;
}

.timeline-header p {
  margin: 0.4rem 0 0.9rem;
  color: #475569;
  font-size: 0.92rem;
}

.timeline-search-row {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 0.5rem;
}

.timeline-search-row input,
.timeline-search-row select {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
}

.timeline-search-row button {
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
}

.timeline-status {
  margin: 0.8rem 0 0.45rem;
  color: #334155;
  font-size: 0.86rem;
}

.timeline-group {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.6rem;
}

.timeline-group h2 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  color: #0f172a;
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  border-top: 1px solid #edf2f7;
  padding: 0.5rem 0;
}

.timeline-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.timeline-item-head {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}

.timeline-item-title {
  font-size: 0.92rem;
  color: #0f172a;
  font-weight: 600;
}

.timeline-item-kind {
  font-size: 0.72rem;
  color: #64748b;
  text-transform: uppercase;
}

.timeline-item-content,
.timeline-item-attachment,
.timeline-item-meta {
  font-size: 0.82rem;
  color: #475569;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.layer-filter-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.38rem 0.5rem;
  font-size: 0.82rem;
  background: #ffffff;
  color: #0f172a;
  margin-bottom: 0.4rem;
  box-sizing: border-box;
}

.layer-filter-input:focus {
  outline: 2px solid #0f172a;
  outline-offset: 0;
}

.layer-feedback {
  margin-top: 0.5rem;
  font-size: 0.76rem;
  color: #334155;
  background: #eef2f7;
  border: 1px solid #d7e0ec;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
}

.layer-item {
  display: grid;
  grid-template-columns: auto 14px 1fr;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  background: #ffffff;
  border: 1px solid #dcebd8;
}

.layer-item:hover {
  border-color: #8ec28c;
  background: #f3fbef;
}

.layer-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.layer-name {
  color: #1f2937;
  font-size: 0.95rem;
}

.layer-item-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.layer-map-name {
  color: #667085;
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.layer-count {
  color: #0f766e;
  font-size: 0.72rem;
  margin-top: 0.2rem;
  font-weight: 600;
}

.layer-item:has(.layer-toggle:disabled) {
  opacity: 0.62;
  cursor: not-allowed;
}

.search-bar-top {
  width: 100%;
  background: linear-gradient(90deg, #f7fff3 0%, #ebf8e7 100%);
  border-bottom: 1px solid #cfe6c8;
  padding: 12px 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(47, 111, 62, 0.08);
  position: relative;
  z-index: 1000;
  grid-column: 1 / -1;
  grid-row: 1;
  overflow-y: auto;
}

.layer-sidebar {
  background: linear-gradient(180deg, #fefefe 0%, #f5f7fb 100%);
  border-right: 1px solid #d9dee7;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 300px;
  flex-shrink: 0;
  grid-column: 1;
  grid-row: 2;
}

.map-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
  grid-column: 2;
  grid-row: 2;
}

#main-map {
  width: 100%;
  height: 100%;
  min-height: 0;
}



@media (max-width: 900px) {
  .map-shell {
    flex-direction: column;
    height: auto;
    max-height: none;
  }

  .layer-sidebar {
    border-right: 0;
    border-bottom: 1px solid #d9dee7;
    max-height: 42vh;
    overflow-y: auto;
  }

  .map-panel {
    flex: 0 0 400px;
  }

  #main-map {
    min-height: 440px;
    height: 58vh;
  }

  .map-overlay-controls {
    max-width: calc(100vw - 24px);
    max-height: 40vh;
  }

  .timeline-search-row {
    grid-template-columns: 1fr;
  }
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}