:root {
  --ink: #172026;
  --muted: #63717c;
  --line: #dbe3e5;
  --paper: #f6f7f4;
  --white: #ffffff;
  --green: #2f9d62;
  --yellow: #d9a62e;
  --red: #c84b42;
  --teal: #2d7f86;
  --navy: #203a4a;
  --shadow: 0 18px 42px rgba(28, 45, 55, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(45, 127, 134, 0.12), transparent 34%),
    linear-gradient(240deg, rgba(217, 166, 46, 0.16), transparent 38%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.map-open {
  overflow: hidden;
}

a,
button {
  font: inherit;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.project-header,
.lot-card,
.admin-preview,
.map-summary,
.admin-hero,
.admin-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(219, 227, 229, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
}

.eyebrow,
.section-label {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.32rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.login-button,
.admin-preview button,
.map-link,
.primary-action,
.secondary-action {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  background: var(--navy);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
}

.project-copy,
.admin-preview p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.map-link {
  flex: 0 0 auto;
  background: var(--teal);
}

.project-actions {
  display: grid;
  gap: 8px;
}

.quiet-link {
  color: var(--navy);
  background: #dbe7e5;
}

.map-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
}

.map-summary p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.status-strip span {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.82);
  color: #34434c;
  font-size: 0.78rem;
  font-weight: 750;
  text-align: center;
}

.dot {
  width: 9px;
  height: 9px;
  margin-right: 5px;
  display: inline-block;
  border-radius: 50%;
}

.available {
  background: var(--green);
}

.reserved {
  background: var(--yellow);
}

.sold {
  background: var(--red);
}

.map-panel {
  position: relative;
  --map-zoom: 1;
  --map-pan-x: 0px;
  --map-pan-y: 0px;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid #c9d6d7;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(32, 58, 74, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(32, 58, 74, 0.08) 1px, transparent 1px),
    #e8eee9;
  background-size: 28px 28px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.62);
  cursor: grab;
  touch-action: none;
}

.map-panel.satellite-mode {
  background: #172026;
}

.map-panel.is-panning {
  cursor: grabbing;
}

.map-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  padding: 10px;
  background: #eef2ef;
}

.map-screen[hidden] {
  display: none;
}

.map-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 12px;
  background: rgba(238, 242, 239, 0.96);
}

.map-screen-header h2 {
  margin-bottom: 0;
}

.map-screen .map-panel {
  min-height: 0;
  height: 100%;
  border-radius: 8px;
  box-shadow: none;
}

.map-screen .lot-card {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 6;
  margin: 0 auto;
  max-width: 720px;
  padding: 12px;
  box-shadow: 0 -8px 28px rgba(28, 45, 55, 0.12);
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.map-screen .lot-card.is-hidden {
  pointer-events: none;
  opacity: 0;
  transform: translateY(calc(100% + 16px));
}

.plan-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #eef2ef;
  transform: translate(var(--map-pan-x), var(--map-pan-y)) scale(var(--map-zoom));
  transform-origin: center;
  transition: transform 180ms ease;
}

.satellite-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  background: #172026;
  transition: opacity 160ms ease;
}

.satellite-map::after {
  position: absolute;
  inset: 0;
  z-index: 470;
  pointer-events: none;
  content: "";
  box-shadow: inset 0 0 38px 20px rgba(238, 242, 239, 0.42);
}

.map-panel.satellite-mode .satellite-map {
  opacity: 1;
  pointer-events: auto;
}

.map-panel.satellite-mode .demo-plan,
.map-panel.satellite-mode .plan-image,
.map-panel.satellite-mode .zone-layer {
  opacity: 0;
  pointer-events: none;
}

.map-panel.satellite-mode .north {
  z-index: 550;
}

.demo-plan {
  position: absolute;
  inset: 0;
  transform: translate(var(--map-pan-x), var(--map-pan-y)) scale(var(--map-zoom));
  transform-origin: center;
  transition: transform 180ms ease;
}

.zone-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.map-tools {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: 34px 1fr 34px 42px 42px;
  gap: 6px;
  width: min(300px, calc(100% - 74px));
  padding: 7px;
  border: 1px solid rgba(219, 227, 229, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(28, 45, 55, 0.12);
}

.zoom-button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--navy);
  background: #dbe7e5;
  font-weight: 900;
  cursor: pointer;
}

.map-mode-toggle.is-active {
  color: #ffffff;
  background: var(--teal);
}

.satellite-lot-label,
.satellite-block-label,
.satellite-project-label,
.satellite-dimension-label,
.satellite-donation-label {
  width: auto !important;
  height: auto !important;
  border: 0;
  background: transparent;
}

.satellite-lot-label span,
.satellite-block-label span,
.satellite-project-label span,
.satellite-dimension-label span,
.satellite-donation-label span {
  display: block;
  white-space: nowrap;
  color: #ffffff;
  font-weight: 900;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 0 4px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
}

.satellite-lot-label span {
  font-size: 9px;
  line-height: 1.05;
  text-align: center;
}

.satellite-lot-label small {
  display: block;
  max-width: 62px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 6px;
  font-weight: 800;
  text-overflow: ellipsis;
}

.satellite-dimension-label span {
  padding: 1px 3px;
  border-radius: 3px;
  background: rgba(5, 7, 10, 0.58);
  color: #ffffff;
  font-size: 8px;
  font-weight: 850;
  line-height: 1;
  transform: translate(-50%, -50%) rotate(var(--label-angle, 0deg));
  transform-origin: center;
}

.satellite-donation-label span {
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(0, 82, 38, 0.78);
  color: #ffffff;
  font-size: 10px;
  font-weight: 950;
}

.satellite-block-label span {
  color: #101820;
  font-size: 16px;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    0 -1px 0 rgba(255, 255, 255, 0.95),
    1px 0 0 rgba(255, 255, 255, 0.95),
    -1px 0 0 rgba(255, 255, 255, 0.95);
}

.satellite-project-label span {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 4px;
  background: rgba(16, 24, 32, 0.62);
  font-size: 18px;
  letter-spacing: 0;
}

.leaflet-container {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.leaflet-tile-pane {
  filter: drop-shadow(0 0 8px rgba(23, 32, 38, 0.32));
}

.leaflet-control-attribution {
  font-size: 10px;
}

#zoomRange {
  min-height: 32px;
  margin: 0;
  padding: 0;
}

.zones-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  shape-rendering: geometricPrecision;
}

.zone-shape {
  cursor: pointer;
  fill-opacity: 0.18;
  stroke: rgba(10, 14, 18, 0.72);
  stroke-linejoin: round;
  stroke-width: 0.22px;
  stroke-opacity: 0.72;
  vector-effect: non-scaling-stroke;
}

.donation-shape {
  fill: #00a651;
  fill-opacity: 0.46;
  stroke: #034f25;
  stroke-width: 0.42px;
  stroke-opacity: 0.95;
  vector-effect: non-scaling-stroke;
}

.donation-label {
  fill: #ffffff;
  stroke: rgba(0, 73, 34, 0.9);
  stroke-width: 0.18px;
  font-size: 0.62px;
  font-weight: 950;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke fill;
}

.zone-shape.available {
  fill: var(--green);
}

.zone-shape.reserved {
  fill: var(--yellow);
}

.zone-shape.sold {
  fill: var(--red);
}

.zone-shape.is-selected {
  stroke: #05070a;
  fill-opacity: 0.62;
  stroke-width: 0.45px;
  stroke-opacity: 0.9;
}

.zone-label,
.block-label {
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke fill;
}

.zone-label {
  fill: #ffffff;
  stroke: rgba(7, 10, 12, 0.72);
  stroke-width: 0.08px;
  font-size: 0.22px;
  font-weight: 900;
  display: none;
}

.block-label {
  fill: #101820;
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 0.18px;
  font-size: 1.18px;
  font-weight: 900;
}

.map-panel.show-labels .zone-shape {
  fill-opacity: 0.36;
  stroke-opacity: 0.64;
}

.map-panel.show-labels .zone-label {
  display: block;
}

.map-panel.show-labels .block-label {
  display: none;
}

.zone {
  position: absolute;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 5px;
  color: var(--white);
  box-shadow: 0 8px 18px rgba(28, 45, 55, 0.2);
  cursor: pointer;
}

.zone span {
  display: none;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.map-panel.show-labels .zone span {
  display: block;
}

.zone.is-selected {
  outline: 4px solid rgba(32, 58, 74, 0.36);
  outline-offset: 2px;
}

.north {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--navy);
  border-radius: 50%;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.86);
  font-weight: 900;
}

.north::before {
  content: "";
  position: absolute;
  top: -13px;
  border-right: 7px solid transparent;
  border-bottom: 13px solid var(--navy);
  border-left: 7px solid transparent;
}

.road {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  color: rgba(23, 32, 38, 0.66);
  background: #c6c0b4;
  font-size: 0.76rem;
  font-weight: 800;
}

.road-main {
  left: -20px;
  right: -20px;
  bottom: 62px;
  height: 48px;
  transform: rotate(-5deg);
}

.road-side {
  top: -20px;
  bottom: 110px;
  left: 42px;
  width: 42px;
  writing-mode: vertical-rl;
}

.green-area {
  position: absolute;
  right: 20px;
  bottom: 124px;
  z-index: 1;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #245b3d;
  background: #b9d8b5;
  font-size: 0.72rem;
  font-weight: 850;
  text-align: center;
}

.lot-grid {
  position: absolute;
  top: 72px;
  left: 104px;
  z-index: 2;
  width: min(280px, calc(100% - 126px));
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  gap: 7px;
  transform: rotate(-5deg);
}

.lot {
  min-height: 68px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  color: var(--white);
  box-shadow: 0 8px 18px rgba(28, 45, 55, 0.18);
  cursor: pointer;
}

.lot span {
  display: block;
  font-size: 0.82rem;
  font-weight: 900;
}

.lot small {
  display: block;
  font-size: 0.66rem;
  font-weight: 750;
}

.lot.is-selected {
  outline: 4px solid rgba(32, 58, 74, 0.35);
  outline-offset: 2px;
}

.lot-card {
  margin-top: 14px;
  padding: 16px;
}

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

.state-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--white);
  font-size: 0.76rem;
  font-weight: 850;
}

.map-screen .lot-card-header {
  align-items: center;
}

.map-screen .lot-details {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.map-screen .lot-details div {
  padding: 8px;
}

.map-screen dt {
  font-size: 0.66rem;
}

.map-screen dd {
  font-size: 0.78rem;
}

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

.lot-details div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf8;
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

dd {
  margin: 2px 0 0;
  font-weight: 850;
}

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

.primary-action {
  background: #16884f;
}

.secondary-action {
  color: var(--navy);
  background: #dbe7e5;
}

.admin-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
}

.admin-preview button {
  flex: 0 0 auto;
  background: var(--teal);
}

.admin-view {
  margin-top: 14px;
}

.admin-hero,
.admin-card {
  margin-top: 14px;
  padding: 16px;
}

.admin-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

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

label {
  min-width: 0;
  color: #40515a;
  font-size: 0.78rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  border: 1px solid #cdd8da;
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fbfcfb;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(45, 127, 134, 0.16);
}

textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.35;
}

.full-field {
  grid-column: 1 / -1;
}

.wide-action {
  width: 100%;
  margin-top: 10px;
  border: 0;
}

.helper-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.lot-table {
  display: grid;
  gap: 8px;
}

.lot-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf8;
}

.lot-row strong,
.lot-row small {
  display: block;
}

.lot-row strong {
  font-size: 0.92rem;
}

.lot-row small {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 700;
}

.mini-state {
  align-self: start;
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 850;
}

.plan-editor {
  position: relative;
  min-height: 320px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px dashed #a9b9bd;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(32, 58, 74, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(32, 58, 74, 0.07) 1px, transparent 1px),
    #eef2ef;
  background-size: 24px 24px;
}

.empty-plan {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.compact-controls {
  margin-top: 10px;
}

@media (max-width: 380px) {
  .app-shell {
    padding: 12px;
  }

  .project-header,
  .admin-preview,
  .map-summary,
  .admin-hero {
    display: block;
  }

  .map-link,
  .admin-preview button,
  .map-summary button,
  .admin-hero button {
    width: 100%;
    margin-top: 12px;
  }

  .project-actions {
    margin-top: 12px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .lot-grid {
    left: 88px;
    width: calc(100% - 108px);
  }

  .form-grid,
  .lot-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .map-screen {
    padding: 0;
  }

  .map-screen-header {
    padding: 10px 12px;
  }

  .map-screen .map-panel {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .map-screen .lot-card {
    right: 0;
    bottom: 0;
    left: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .map-screen .lot-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
