:root {
  --bg: #eef2f0;
  --panel: #fbfcfa;
  --ink: #18212b;
  --muted: #64717d;
  --line: #d7ded8;
  --soft: #eef4ef;
  --accent: #256d5a;
  --green: #15803d;
  --lime: #84cc16;
  --red: #dc2626;
  --orange: #f97316;
  --blue: #0284c7;
  --yellow: #eab308;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 392px) 1fr;
  width: 100%;
  height: 100%;
  min-height: 680px;
}

.sidebar {
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 26px;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 30px rgba(24, 33, 43, 0.08);
}

.brand-block {
  display: grid;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 31px;
  line-height: 1.05;
}

.data-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-item {
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8faf8 100%);
}

.summary-item span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-item.available {
  border-color: rgba(21, 128, 61, 0.35);
}

.summary-item.market {
  border-color: rgba(37, 109, 90, 0.42);
  background: linear-gradient(180deg, #ffffff 0%, #edf7f1 100%);
}

.summary-item.observed {
  border-color: rgba(2, 132, 199, 0.34);
}

.summary-item.sold {
  border-color: rgba(220, 38, 38, 0.28);
}

.controls {
  display: grid;
  gap: 15px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.mode-switch button {
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.mode-switch button.is-active {
  color: #ffffff;
  background: var(--accent);
}

body[data-mode="public"] .saved-panel,
body[data-mode="public"] #open-notion,
body[data-mode="public"] .internal-only {
  display: none;
}

body.tools-enabled .internal-only {
  display: grid;
}

body.tools-enabled .map-mode-field {
  padding: 10px;
  border: 1px solid rgba(37, 109, 90, 0.22);
  border-radius: 8px;
  background: #f3faf6;
}

body.public-site .mode-switch {
  display: none;
}

.discreet-tools-toggle {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 1000;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(24, 33, 43, 0.08);
  cursor: pointer;
}

.discreet-tools-toggle:hover,
body.tools-enabled .discreet-tools-toggle {
  background: rgba(37, 109, 90, 0.42);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid rgba(37, 109, 90, 0.2);
  border-color: rgba(37, 109, 90, 0.55);
}

.field textarea {
  resize: vertical;
  line-height: 1.35;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

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

.switch-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px;
  color: #33404d;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.clear-button {
  min-height: 42px;
  color: #ffffff;
  font-weight: 800;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  cursor: pointer;
}

.clear-button:hover {
  background: #1f5d4d;
}

.lot-panel {
  display: grid;
  gap: 14px;
  margin-top: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.results-panel {
  display: grid;
  gap: 10px;
  min-height: 160px;
}

.saved-panel {
  display: grid;
  gap: 10px;
}

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

.save-row input {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.save-row button,
.saved-item button {
  min-height: 36px;
  padding: 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(37, 109, 90, 0.28);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.saved-list {
  display: grid;
  gap: 7px;
  max-height: 180px;
  overflow: auto;
  padding-right: 4px;
}

.saved-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.saved-item div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.saved-item strong,
.saved-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-item strong {
  font-size: 13px;
}

.saved-item small {
  color: var(--muted);
  font-size: 12px;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.results-head h2 {
  font-size: 16px;
}

.results-head span {
  min-width: 38px;
  padding: 5px 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  border-radius: 999px;
  background: #e5f1eb;
}

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

.quick-actions button {
  min-height: 34px;
  padding: 0 8px;
  overflow: hidden;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(37, 109, 90, 0.24);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.quick-actions button:hover {
  border-color: rgba(37, 109, 90, 0.48);
  background: #edf7f1;
}

.results-list {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.portfolio-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(37, 109, 90, 0.18);
  border-radius: 8px;
  background: #f7fbf8;
}

.portfolio-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.portfolio-grid div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.portfolio-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.portfolio-grid dd {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#portfolio-statuses {
  grid-column: auto;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.result-item:hover {
  border-color: rgba(37, 109, 90, 0.42);
  background: #f7fbf8;
}

.result-item span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.result-item strong,
.result-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-item strong {
  font-size: 13px;
}

.result-item small {
  color: var(--muted);
  font-size: 12px;
}

.result-item b {
  max-width: 88px;
  overflow: hidden;
  color: #26323d;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-note {
  padding: 8px 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.proposal-view {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  overflow: auto;
  padding: 28px;
  background: #e5e9e6;
}

.proposal-view.is-open {
  display: block;
}

.proposal-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  max-width: 1040px;
  margin: 0 auto 14px;
}

.proposal-toolbar button {
  min-height: 38px;
  padding: 0 14px;
  color: #ffffff;
  font-weight: 800;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  cursor: pointer;
}

.proposal-sheet {
  max-width: 1040px;
  margin: 0 auto;
  padding: 34px;
  color: #17212b;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(24, 33, 43, 0.16);
}

.proposal-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 2px solid #dfe6e1;
}

.proposal-header p {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.proposal-header h1 {
  margin-top: 6px;
  font-size: 28px;
}

.proposal-header span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.proposal-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.proposal-summary div {
  padding: 14px;
  border: 1px solid #dfe6e1;
  border-radius: 8px;
  background: #f8fbf9;
}

.proposal-summary span {
  display: block;
  font-size: 20px;
  font-weight: 900;
}

.proposal-summary p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.proposal-section {
  margin-top: 22px;
}

.proposal-section h2 {
  margin-bottom: 10px;
  font-size: 17px;
}

.proposal-section p {
  color: #33404d;
  line-height: 1.45;
}

.proposal-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.proposal-section th,
.proposal-section td {
  padding: 8px 7px;
  text-align: left;
  border-bottom: 1px solid #e3e8e4;
}

.proposal-section th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.proposal-view[data-mode="public"] .proposal-section th:nth-child(4),
.proposal-view[data-mode="public"] .proposal-section td:nth-child(4) {
  display: none;
}

@media print {
  body {
    background: #ffffff;
  }

  .app-shell,
  .proposal-toolbar {
    display: none !important;
  }

  .proposal-view,
  .proposal-view.is-open {
    position: static;
    display: block;
    overflow: visible;
    padding: 0;
    background: #ffffff;
  }

  .proposal-sheet {
    max-width: none;
    padding: 0;
    box-shadow: none;
  }
}

.lot-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-kicker {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill {
  max-width: 128px;
  padding: 6px 8px;
  overflow: hidden;
  background: var(--status-color, #94a3b8);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 999px;
  background: #64748b;
}

.status-pill[data-status="disponible 1"],
.status-pill[data-status="disponible 2"] {
  background: var(--green);
}

.status-pill[data-status="observado 1"],
.status-pill[data-status="observado 2"] {
  background: var(--blue);
}

.status-pill[data-status="vendido"] {
  background: var(--red);
}

.status-pill[data-status="gestionado"] {
  background: var(--orange);
}

.status-pill[data-status="reservado"],
.status-pill[data-status="pre reservado"] {
  color: #ffffff;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.detail-grid div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.detail-grid .detail-wide {
  grid-column: 1 / -1;
}

.lot-panel dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.lot-panel dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 0;
}

.flag-row span {
  padding: 6px 8px;
  color: #24483f;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid rgba(37, 109, 90, 0.22);
  border-radius: 999px;
  background: #ffffff;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.secondary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid rgba(37, 109, 90, 0.32);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.secondary-button:disabled,
.secondary-link.disabled {
  color: #94a3b8;
  border-color: var(--line);
  pointer-events: none;
  cursor: default;
}

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

#map {
  width: 100%;
  height: 100%;
  background: #dce7e0;
}

.map-status {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 500;
  padding: 10px 12px;
  color: #26323d;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.16);
}

.map-legend {
  position: absolute;
  right: 18px;
  bottom: 70px;
  z-index: 500;
  width: min(240px, calc(100% - 36px));
  padding: 12px;
  color: #25313c;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.16);
}

.map-legend h2 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.legend-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 10px;
}

.legend-title {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.legend-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  padding: 4px 5px;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.legend-item:hover,
.legend-item.is-active {
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.16);
  background: rgba(15, 23, 42, 0.07);
}

.legend-item-static {
  cursor: default;
}

.legend-item-static:hover {
  border-color: transparent;
  background: transparent;
}

.legend-item i {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border: 1px solid rgba(15, 23, 42, 0.28);
  border-radius: 3px;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.popup-title {
  margin-bottom: 8px;
  font-weight: 800;
}

.popup-meta {
  display: grid;
  gap: 4px;
  min-width: 170px;
  color: #33404d;
  font-size: 13px;
}

.lot-label {
  color: #1f2933;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  border: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
}

.leaflet-tooltip-top.lot-label::before,
.leaflet-tooltip-bottom.lot-label::before,
.leaflet-tooltip-left.lot-label::before,
.leaflet-tooltip-right.lot-label::before {
  display: none;
}

.leaflet-control-zoom a {
  color: #18212b;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 1fr);
    min-height: 100%;
  }

  .sidebar {
    max-height: 48vh;
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-grid,
  .switch-grid {
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .summary-item {
    min-width: 120px;
  }
}
