* {
  box-sizing: border-box;
}


/* =========================
   GLOBAL
   ========================= */

:root {
  --toolbar-height: 58px;

  --border: #d9dee7;

  --text: #253043;

  --muted: #8d96a5;

  --surface: #ffffff;
}


html,
body {
  width: 100%;
  height: 100%;

  margin: 0;

  overflow: hidden;

  font-family:
    Arial,
    Helvetica,
    sans-serif;

  color: var(--text);

  background: #ffffff;
}


body {
  display: flex;

  flex-direction: column;
}


/* =========================
   TOOLBAR
   ========================= */

.toolbar {

  min-height: var(--toolbar-height);

  width: 100%;

  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 8px;

  padding: 7px 10px;

  background: #ffffff;

  border-bottom: 1px solid #e7eaf0;

  z-index: 10;
}


.toolbar-left {

  min-width: 0;

  display: flex;

  align-items: center;

  gap: 8px;

  flex: 1;
}


/* =========================
   TAG INPUT
   ========================= */

.tag-wrapper {

  position: relative;

  flex: 0 1 295px;

  min-width: 170px;
}


.tag-input {

  width: 100%;

  height: 38px;

  padding: 0 14px;

  border: 1px solid var(--border);

  border-radius: 9px;

  outline: none;

  font-size: 14px;

  color: var(--text);

  background: #ffffff;

  box-shadow:
    0 1px 3px rgba(30, 45, 65, 0.04);
}


.tag-input::placeholder {

  color: #9ca4b1;
}


.tag-input:focus {

  border-color: #7baef8;

  box-shadow:
    0 0 0 3px rgba(12, 107, 249, 0.10);
}


/* =========================
   COLOUR SELECTOR
   ========================= */

.color-selector {

  display: flex;

  align-items: center;

  gap: 8px;

  flex: 0 0 auto;
}


.color-btn {

  width: 24px;

  height: 24px;

  padding: 0;

  border: 0;

  border-radius: 50%;

  cursor: pointer;

  position: relative;

  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);

  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

.color-btn.square {
  border-radius: 4px;
}


.color-btn:hover {

  transform: scale(1.08);
}


.color-btn.selected {

  box-shadow:
    0 0 0 3px #ffffff,
    0 0 0 5px currentColor;
}


/* =========================
   ADDRESS SEARCH
   ========================= */

.address-wrapper {

  position: relative;

  flex: 0 1 300px;

  min-width: 170px;
}


.address-autocomplete-host {

  width: 100%;

  height: 38px;
}


.address-autocomplete-host gmp-place-autocomplete {

  width: 100%;

  display: block;
}


.address-input {

  width: 100%;

  height: 38px;

  padding: 0 10px;

  border: 1px solid var(--border);

  border-radius: 9px;

  outline: none;

  font-size: 14px;

  color: var(--text);

  background: #ffffff;

  box-shadow:
    0 1px 3px rgba(30, 45, 65, 0.04);
}


.address-input::placeholder {

  color: #9ca4b1;
}


.address-input:focus {

  border-color: #7baef8;

  box-shadow:
    0 0 0 3px rgba(12, 107, 249, 0.10);
}


.address-search-btn {

  position: absolute;

  right: 6px;

  top: 6px;

  width: 40px;

  height: 40px;

  border: 0;

  border-radius: 7px;

  background: #f1f4f8;

  color: #526074;

  font-size: 23px;

  cursor: pointer;
}


.address-search-btn:hover {

  background: #e7ebf1;
}


/* =========================
   SETTINGS
   ========================= */

.settings-btn {

  width: 44px;

  height: 44px;

  flex: 0 0 auto;

  border: 0;

  background: transparent;

  color: #526074;

  font-size: 29px;

  cursor: pointer;

  line-height: 1;

  transition: transform 150ms ease;
}


.settings-btn:hover {

  color: #26364e;

  transform: rotate(20deg);
}


/* =========================
   MAP
   ========================= */

#map {

  flex: 1;

  min-height: 0;

  width: 100%;
}


/* =========================
   STATUS
   ========================= */

.status-message {

  position: fixed;

  left: 50%;

  bottom: 18px;

  transform: translateX(-50%);

  padding: 10px 16px;

  border-radius: 8px;

  background: rgba(31, 42, 57, 0.90);

  color: #ffffff;

  font-size: 14px;

  opacity: 0;

  pointer-events: none;

  transition: opacity 180ms ease;

  z-index: 20;
}


.status-message.visible {

  opacity: 1;
}


/* =========================
   MODAL
   ========================= */

.modal {

  position: fixed;

  inset: 0;

  z-index: 100;

  display: flex;

  align-items: center;

  justify-content: center;

  padding: 24px;

  background: rgba(20, 30, 45, 0.45);
}


.modal.hidden {

  display: none;
}


.modal-card {

  width: min(1400px, 100%);

  max-height: min(850px, 92vh);

  display: flex;

  flex-direction: column;

  background: #ffffff;

  border-radius: 12px;

  box-shadow:
    0 20px 70px rgba(20, 30, 45, 0.25);

  overflow: hidden;
}


/* =========================
   MODAL HEADER
   ========================= */

.modal-header {

  display: flex;

  align-items: center;

  justify-content: space-between;

  padding: 18px 22px;

  border-bottom: 1px solid #e5e9ef;
}


.modal-header h2 {

  margin: 0;

  font-size: 21px;
}


.close-btn {

  border: 0;

  background: transparent;

  font-size: 31px;

  color: #667387;

  cursor: pointer;
}


/* =========================
   EXPORT SUMMARY
   ========================= */

.export-summary {

  display: flex;

  gap: 18px;

  padding: 12px 22px;

  color: #667387;

  font-size: 14px;
}


/* =========================
   EXPORT TABLE
   ========================= */

.table-container {

  overflow: auto;

  padding: 0 22px 18px;
}


#exportTable {

  width: 100%;

  border-collapse: collapse;

  font-size: 13px;
}


#exportTable th,
#exportTable td {

  padding: 10px 9px;

  text-align: left;

  border-bottom: 1px solid #e8ebf0;

  white-space: nowrap;
}


#exportTable th {

  position: sticky;

  top: 0;

  background: #f7f8fa;

  color: #4c596d;
}


/* =========================
   COLOUR CELL
   ========================= */

.colour-cell {

  display: inline-flex;

  align-items: center;

  gap: 7px;
}


.colour-swatch {

  width: 15px;

  height: 15px;

  border-radius: 50%;

  display: inline-block;

  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.10);
}


/* =========================
   MODAL BUTTONS
   ========================= */

.modal-actions {

  display: flex;

  justify-content: flex-end;

  gap: 10px;

  padding: 15px 22px;

  border-top: 1px solid #e5e9ef;
}


.primary-btn,
.danger-btn {

  min-height: 40px;

  padding: 0 17px;

  border-radius: 7px;

  border: 0;

  cursor: pointer;

  font-weight: 600;
}


.primary-btn {

  background: #0c6bf9;

  color: #ffffff;
}


.primary-btn:hover {

  background: #095bd5;
}


.danger-btn {

  background: #fbe8e7;

  color: #b62e28;
}


.danger-btn:hover {

  background: #f7d8d6;
}


/* =========================
   TABLET
   ========================= */

@media (max-width: 1050px) {

  .toolbar {

    padding: 10px 14px;
  }


  .toolbar-left {

    gap: 12px;
  }


  .color-selector {

    gap: 10px;
  }


  .color-btn {

    width: 25px;

    height: 25px;
  }


  .tag-wrapper {

    flex-basis: 210px;
  }


  .address-wrapper {

    flex-basis: 240px;
  }

}


/* =========================
   MOBILE
   ========================= */

@media (max-width: 780px) {

  :root {

    --toolbar-height: auto;
  }


  .toolbar {

    align-items: flex-start;

    padding: 10px;
  }


  .toolbar-left {

    flex-wrap: wrap;

    row-gap: 10px;
  }


  .tag-wrapper,
  .address-wrapper {

    flex: 1 1 230px;
  }


  .color-selector {

    order: 3;

    width: 100%;

    justify-content: center;

    gap: 16px;

    padding: 2px 0;
  }


  .settings-btn {

    position: absolute;

    right: 8px;

    top: 8px;
  }


  .tag-wrapper {

    padding-right: 40px;
  }

}


/* =========================
   SMALL MOBILE
   ========================= */

@media (max-width: 480px) {

  .toolbar-left {

    width: 100%;
  }


  .tag-wrapper,
  .address-wrapper {

    flex-basis: 100%;
  }


  .color-selector {

    gap: 11px;
  }


  .color-btn {

    width: 24px;

    height: 24px;
  }


  .modal {

    padding: 8px;
  }


  .modal-actions {

    flex-wrap: wrap;
  }

}
/* Batch 3 */
#exportTable th[data-sort] {
  cursor: pointer;
  user-select: none;
}

#exportTable th[data-sort]:hover {
  text-decoration: underline;
}

#exportTable tbody tr {
  cursor: pointer;
}

#exportTable tbody tr:hover {
  background: #f5f8fc;
}

.map-attribution {
  position: fixed;
  right: 8px;
  bottom: 8px;
  z-index: 5;
  padding: 2px 6px;
  font-size: 10px;
  color: #596273;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 3px;
  pointer-events: none;
}

/* =========================
   BATCH 4 RESPONSIVE POLISH
   ========================= */
.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
  color: #526074;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.icon-button:hover {
  background: #f5f7fa;
}

.icon-button:focus-visible,
.settings-btn:focus-visible,
.color-btn:focus-visible {
  outline: 3px solid rgba(12, 107, 249, 0.20);
  outline-offset: 2px;
}

#exportTable tbody tr {
  cursor: pointer;
}

#exportTable tbody tr:hover {
  background: #f6f8fb;
}

@media (max-width: 760px) {
  :root { --toolbar-height: 104px; }

  .toolbar {
    min-height: var(--toolbar-height);
    padding: 6px 8px;
    align-items: flex-start;
  }

  .toolbar-left {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 38px 38px;
    gap: 6px;
  }

  .tag-wrapper {
    min-width: 0;
    width: 100%;
  }

  .address-wrapper {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }

  .color-selector {
    gap: 5px;
    justify-content: flex-end;
  }

  .color-btn {
    width: 22px;
    height: 22px;
  }

  .icon-button,
  .settings-btn {
    width: 36px;
    height: 36px;
  }

  .settings-btn {
    font-size: 25px;
  }

  .modal {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-card {
    max-height: 94vh;
    border-radius: 12px 12px 0 0;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .table-container {
    padding: 0 12px 12px;
  }

  #exportTable {
    min-width: 760px;
  }
}


/* Export-row selection */
#exportTable th:first-child, #exportTable td.select-cell { width: 54px; text-align: center; }
#exportTable .export-row-checkbox { width: 16px; height: 16px; cursor: pointer; }


/* Client feedback: make active drawing/selection tools visibly pressed. */
.icon-button.active {
  background: #dbeafe !important;
  border: 2px solid #2563eb !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.22);
  transform: translateY(1px);
}
.icon-button[aria-pressed="true"] {
  background: #dbeafe;
}

/* Database property lookup / export processing feedback */
.export-processing-status {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f3f5f8;
  color: #394150;
  font-size: 12px;
}
#exportCsvBtn:disabled {
  opacity: .55;
  cursor: not-allowed;
}


/* Building data provider settings */
.provider-settings {
  margin: 12px 22px 8px;
  padding: 14px 16px;
  border: 1px solid #e3e8ef;
  border-radius: 9px;
  background: #f8fafc;
}
.provider-settings h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: #263449;
}
.provider-settings-help {
  margin: 5px 0 10px;
  color: #667387;
  font-size: 12px;
  line-height: 1.45;
}
.provider-settings label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #465469;
}
.provider-select {
  width: min(420px, 100%);
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #cbd4df;
  border-radius: 6px;
  background: #fff;
  color: #263449;
  font: inherit;
}
.provider-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 9px;
  font-size: 12px;
}
.provider-terms a {
  color: #075ecb;
  text-decoration: underline;
}

/* ==========================================================
   SETTINGS UI IMPROVEMENTS - RESPONSIVE
   ========================================================== */

/* Building provider settings */
.building-provider-settings {
  padding: 20px 22px;
  margin: 0;
  border-bottom: 1px solid #e5e9f0;
  background: #ffffff;
  color: #263448;
}

.building-provider-settings h3 {
  margin: 0 0 16px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
}

.building-provider-settings label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

#buildingProviderSelect {
  display: block;
  width: 100%;
  max-width: 440px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #cbd3df;
  border-radius: 8px;
  background: #ffffff;
  color: #263448;
  font-size: 15px;
  cursor: pointer;
}

#buildingProviderSelect:focus {
  outline: 2px solid #0c6bf9;
  outline-offset: 2px;
}

.building-provider-settings p {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.building-provider-settings a {
  color: #075bd8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.building-provider-settings a:hover {
  color: #0345a8;
}

#buildingProviderStatus {
  color: #526176;
  font-size: 13px;
}

/* Settings modal spacing */
.modal-card {
  overflow: hidden;
}

.modal-header {
  flex-shrink: 0;
}

.export-summary {
  flex-shrink: 0;
}

/* Export table */
.table-container {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#exportTable {
  white-space: nowrap;
}

/* Action buttons */
.modal-actions {
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
}

.modal-actions button {
  min-height: 40px;
}

/* Mobile layout */
@media (max-width: 760px) {

  .modal-card {
    width: 100%;
    max-height: 94dvh;
    border-radius: 14px 14px 0 0;
  }

  .building-provider-settings {
    padding: 16px;
  }

  .building-provider-settings h3 {
    font-size: 18px;
    margin-bottom: 12px;
  }

  #buildingProviderSelect {
    max-width: none;
    width: 100%;
    min-height: 46px;
    font-size: 16px;
  }

  .building-provider-settings p {
    font-size: 13px;
    line-height: 1.8;
  }

  .modal-actions {
    justify-content: center;
    gap: 8px;
    padding: 12px;
  }

  .modal-actions button {
    flex: 1 1 110px;
  }

  #exportTable {
    min-width: 760px;
  }
}

/* Small mobile screens */
@media (max-width: 380px) {

  .modal-header h2 {
    font-size: 18px;
  }

  .export-summary {
    gap: 12px;
    padding: 10px 16px;
  }

  .building-provider-settings {
    padding: 14px;
  }

  .modal-actions button {
    flex: 1 1 100%;
  }
}
