:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --ink: #17211a;
  --muted: #637066;
  --line: #d9e1da;
  --green: #2f8a50;
  --yellow: #c58a14;
  --red: #bc3b32;
  --red-green: linear-gradient(135deg, #bc3b32 0 49%, #2f8a50 51% 100%);
  --blue: #2e6f9f;
  --gray: #7c8580;
  --shadow: 0 18px 48px rgba(35, 49, 39, 0.12);
}

* {
  box-sizing: border-box;
}

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

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 440px) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

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

.search-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 138, 80, 0.16);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filter-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
}

.filter-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.contact-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  border: 1px solid #b9d8c2;
  border-radius: 8px;
  background: #eef8f0;
  padding: 12px 14px;
}

.contact-strip div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
}

.contact-strip strong {
  color: var(--ink);
}

.contact-strip a {
  white-space: nowrap;
  border-radius: 8px;
  background: var(--green);
  color: white;
  padding: 10px 12px;
  font-weight: 800;
  text-decoration: none;
}

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

.summary-strip article,
.map-panel,
.detail-card,
.table-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.summary-strip article {
  padding: 14px;
}

.summary-strip span {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.summary-strip p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.map-panel {
  min-width: 0;
  overflow: hidden;
}

.map-header,
.table-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.map-header p,
.table-header p,
#detailSubtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.siteplan-frame {
  width: 100%;
  overflow: auto;
  background: #eef1ed;
  -webkit-overflow-scrolling: touch;
}

.siteplan-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 825.36 / 511.44;
}

.siteplan-canvas img,
.siteplan-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
}

.siteplan-canvas svg {
  position: absolute;
  inset: 0;
}

.lot-shape {
  cursor: pointer;
  fill: #ffffff;
  stroke: rgba(23, 33, 26, 0.26);
  stroke-width: 1.1;
  transition: fill 140ms ease, stroke 140ms ease, stroke-width 140ms ease;
}

.lot-shape.status-terjual-serah {
  fill: rgba(47, 138, 80, 0.28);
  stroke: rgba(47, 138, 80, 0.9);
}

.lot-shape.status-sudah-pecah {
  fill: rgba(197, 138, 20, 0.28);
  stroke: rgba(197, 138, 20, 0.88);
}

.lot-shape.status-batal,
.lot-shape.status-perlu-cek {
  fill: rgba(188, 59, 50, 0.34);
  stroke: rgba(188, 59, 50, 0.95);
}

.lot-shape.status-belum-pecah,
.lot-shape.status-no-data {
  fill: #ffffff;
  stroke: rgba(124, 133, 128, 0.72);
}

.lot-shape.status-proses-ajb {
  fill: url(#redGreenPattern);
  stroke: rgba(23, 33, 26, 0.7);
}

.lot-shape.dimmed {
  fill: rgba(255, 255, 255, 0.02);
  stroke: rgba(23, 33, 26, 0.08);
}

.lot-shape.selected {
  fill: rgba(46, 111, 159, 0.42);
  stroke: #123f63;
  stroke-width: 2.4;
}

.lot-label {
  pointer-events: none;
  fill: #111812;
  font-size: 8px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(23, 33, 26, 0.3);
  border-radius: 4px;
}

.legend-white {
  background: #ffffff;
}

.legend-yellow {
  background: rgba(197, 138, 20, 0.45);
}

.legend-green {
  background: rgba(47, 138, 80, 0.58);
}

.legend-red {
  background: rgba(188, 59, 50, 0.58);
}

.legend-red-green {
  background: var(--red-green);
}

.detail-panel {
  min-width: 0;
}

.detail-card {
  position: sticky;
  top: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

#detailTitle {
  margin-bottom: 4px;
  font-size: 24px;
}

#detailList {
  display: grid;
  grid-template-columns: 125px 1fr;
  gap: 10px 12px;
  margin: 18px 0 0;
}

#detailList dt,
#modalDetailList dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

#detailList dd,
#modalDetailList dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-modal {
  display: none;
}

.warnings {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.warning {
  border-left: 4px solid var(--red);
  border-radius: 6px;
  background: #fff2ef;
  color: #73241f;
  padding: 10px;
  font-size: 13px;
}

.table-section {
  margin-top: 14px;
  overflow: hidden;
}

.table-wrap {
  max-height: 430px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf7;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected-row {
  background: #edf5ee;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.pill-terjual-serah {
  background: var(--green);
}

.pill-sudah-pecah {
  background: var(--yellow);
}

.pill-batal,
.pill-perlu-cek {
  background: var(--red);
}

.pill-belum-pecah,
.pill-no-data {
  background: var(--gray);
}

.pill-proses-ajb {
  background: #7c5d41;
}

@media (max-width: 980px) {
  .toolbar,
  .workspace,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .filters {
    justify-content: flex-start;
  }

  .detail-card {
    position: static;
  }
}

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

  .toolbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 17px;
  }

  .search-box input {
    min-height: 48px;
    font-size: 16px;
  }

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

  .filter-button {
    min-height: 44px;
    padding: 0 8px;
  }

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

  .contact-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .contact-strip a {
    display: block;
    text-align: center;
  }

  .legend {
    display: grid;
    grid-template-columns: 1fr;
    padding: 10px 12px;
  }

  .summary-strip article {
    padding: 11px 9px;
  }

  .summary-strip span {
    font-size: 20px;
  }

  .summary-strip p {
    font-size: 12px;
    line-height: 1.25;
  }

  .siteplan-canvas {
    width: 780px;
  }

  .map-header,
  .table-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
  }

  .detail-card {
    padding: 14px;
  }

  .detail-panel {
    display: none;
  }

  #detailTitle {
    font-size: 22px;
  }

  #detailList {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 9px 10px;
  }

  .detail-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    align-items: end;
    pointer-events: none;
  }

  .detail-modal.open {
    pointer-events: auto;
  }

  .modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(12, 18, 14, 0);
    transition: background 160ms ease;
  }

  .detail-modal.open .modal-backdrop {
    background: rgba(12, 18, 14, 0.42);
  }

  .modal-sheet {
    position: relative;
    max-height: min(78vh, 680px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
    background: var(--surface);
    padding: 10px 16px 18px;
    box-shadow: 0 -18px 46px rgba(19, 32, 24, 0.24);
    transform: translateY(100%);
    transition: transform 180ms ease;
  }

  .detail-modal.open .modal-sheet {
    transform: translateY(0);
  }

  .modal-grip {
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: #c8d1ca;
    margin: 0 auto 12px;
  }

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

  .modal-close {
    display: inline-grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8faf7;
    color: var(--ink);
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
  }

  #modalDetailTitle {
    font-size: 24px;
    margin: 0 0 4px;
  }

  #modalDetailSubtitle {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
  }

  #modalDetailList {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 9px 10px;
    margin: 16px 0 0;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
  }

  td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 8px;
    border-bottom: 0;
    padding: 6px 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }
}
