/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: #0d0f14;
  color: #e8eaf0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #12151d;
  border-bottom: 1px solid #1e2230;
  flex-shrink: 0;
  z-index: 1000;
}

.hbadge {
  background: linear-gradient(135deg, #3b6ffb 0%, #6c4ff5 100%);
  color: #fff;
  border-radius: 7px;
  padding: 4px 11px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
}
header h1 { font-size: 14px; font-weight: 500; color: #d4d8e8; }
header h1 span { color: #7b96ff; }
.hright { margin-left: auto; display: flex; gap: 16px; align-items: center; }
.hstat { font-size: 11px; color: #4a5270; }
#cursor-coords, #header-zoom { color: #8899cc; font-variant-numeric: tabular-nums; }

/* ── App body ─────────────────────────────────────────────────────────────── */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
aside {
  width: 260px;
  flex-shrink: 0;
  background: #12151d;
  border-right: 1px solid #1e2230;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel { padding: 12px 14px; border-bottom: 1px solid #1a1e2a; }

.panel-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #3a4265;
  margin-bottom: 9px;
}

/* ── Layer toggles ───────────────────────────────────────────────────────── */
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  cursor: pointer;
  border-radius: 5px;
  transition: background .1s;
}
.layer-row:hover { background: #171b27; }
.ldot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.lname { font-size: 12px; color: #b8c0d8; flex: 1; }

.toggle { position: relative; width: 32px; height: 17px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: #252a3d; border-radius: 17px;
  cursor: pointer; transition: background .2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle input:checked + .toggle-track { background: #3b6ffb; }
.toggle input:checked + .toggle-track::after { transform: translateX(15px); }

.op-row { display: flex; align-items: center; gap: 7px; padding: 2px 0 7px 16px; }
.op-row label { font-size: 9px; color: #3a4265; width: 22px; flex-shrink: 0; }
.op-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  height: 3px; border-radius: 3px;
  background: #252a3d; outline: none; cursor: pointer;
}
.op-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: #3b6ffb; cursor: pointer;
}
.op-val { font-size: 9px; color: #4a5270; width: 26px; text-align: right; }

/* ── Dot colors ──────────────────────────────────────────────────────────── */
.c-bg     { background: #5577ff; }
.c-cad    { background: #f5a623; }
.c-foret  { background: #3d9e60; }
.c-limit  { background: #e03c5a; }
.c-neigh  { background: #7b96ff; }
.c-grid   { background: #a855f7; }

/* ── Info rows ───────────────────────────────────────────────────────────── */
.irow {
  display: flex; justify-content: space-between;
  padding: 4px 0; font-size: 11px;
  border-bottom: 1px solid #161a26;
}
.irow:last-child { border: none; }
.ik { color: #3a4265; }
.iv { color: #7b9ee8; font-weight: 500; }

/* ── Neighbor list ───────────────────────────────────────────────────────── */
.neighbor-count-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px; font-size: 11px; color: #4a5270;
}
.neighbor-count-row strong { color: #7b96ff; }
#neighbor-list { max-height: 140px; overflow-y: auto; }
.neighbor-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; font-size: 11px; border-bottom: 1px solid #161a26;
  color: #9aaddf;
}
.neighbor-item:last-child { border: none; }
.ni-name { font-size: 11px; }
.ni-code { font-size: 9px; color: #3a4265; }

/* ── Print panel ─────────────────────────────────────────────────────────── */
/* Tile-size slider */
.slider-wrap {
  padding: 4px 0 12px;
}
.slider-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.slider-header .zoom-val {
  font-size: 20px; font-weight: 700; color: #7b96ff; line-height: 1;
}
.slider-header .zoom-hint { font-size: 10px; color: #3a4265; }
input[type=range]#tile-slider {
  -webkit-appearance: none;
  width: 100%; height: 5px; border-radius: 5px;
  background: linear-gradient(90deg, #3b6ffb, #a855f7);
  outline: none; cursor: pointer;
}
input[type=range]#tile-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid #7b96ff;
  cursor: pointer; box-shadow: 0 0 8px rgba(123,150,255,.5);
}
.slider-labels {
  display: flex; justify-content: space-between;
  margin-top: 5px; font-size: 8px; color: #3a4265;
}

/* Radius selector */
.prow {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.prow label { font-size: 9px; color: #3a4265; width: 42px; flex-shrink: 0; }
select {
  flex: 1;
  background: #1a1e2d; border: 1px solid #252a3d; color: #93aae8;
  border-radius: 6px; padding: 5px 8px; font-size: 11px;
  font-family: inherit; cursor: pointer; outline: none;
}
select:focus { border-color: #3b6ffb; }

/* Stats grid */
.pstats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px; margin-bottom: 8px;
}
.pstat {
  background: #171b27; border: 1px solid #1e2230;
  border-radius: 7px; padding: 7px 6px; text-align: center;
}
.pstat .n { font-size: 20px; font-weight: 700; color: #7b96ff; line-height: 1.1; }
.pstat .u { font-size: 8px; color: #3a4265; margin-top: 2px; }

.scale-row {
  display: flex; justify-content: space-between;
  font-size: 10px; color: #3a4265; margin-bottom: 4px;
}
.scale-row span { color: #7b9ee8; }
.cover-row {
  font-size: 10px; color: #3a4265; text-align: center;
  margin-bottom: 10px;
}
.cover-row span { color: #93aae8; }

/* Tile thumbnail grid */
.tg-section { margin-bottom: 10px; }
.tg-layer-label { font-size: 9px; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 5px; }
.tile-grid { display: flex; flex-direction: column; gap: 3px; }
.tile-grid-row { display: flex; gap: 3px; }
.tile-cell {
  min-width: 28px; height: 20px; flex: 1;
  background: #171b27; border: 1px solid #252a3d;
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 500; color: #4a5270;
  cursor: pointer; transition: all .12s;
}
.tile-cell:hover { background: #232842; border-color: #3b6ffb; color: #7b96ff; }
.tile-cell.active { background: #1c2b55; border-color: #3b6ffb; color: #7b96ff; }
.tile-cell.cad { border-left: 2px solid #f5a623; }
.tile-cell.for { border-left: 2px solid #3d9e60; }

/* Print buttons */
.print-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 9px; border: none; border-radius: 8px;
  font-family: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all .2s; margin-bottom: 6px;
}
.print-btn:last-child { margin-bottom: 0; }
.print-btn.cad { background: linear-gradient(135deg,#b8710a,#f5a623); color: #fff; }
.print-btn.for { background: linear-gradient(135deg,#1a6835,#3d9e60); color: #fff; }
.print-btn.combo { background: linear-gradient(135deg,#5b21b6,#8b5cf6); color: #fff; }
.print-btn:hover { opacity: .88; transform: translateY(-1px); }

/* ── Nav buttons ────────────────────────────────────────────────────────── */
.navbtns { display: flex; gap: 5px; flex-wrap: wrap; }
.navbtn {
  flex: 1; min-width: 44px;
  background: #1a1e2d; border: 1px solid #252a3d; color: #7b90cc;
  border-radius: 6px; padding: 5px; font-size: 10px;
  font-family: inherit; cursor: pointer; text-align: center;
  transition: all .12s;
}
.navbtn:hover { background: #232842; color: #7b96ff; border-color: #3b6ffb; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.sidebar-footer {
  position: sticky; bottom: 0;
  margin-top: auto; padding: 10px 14px;
  font-size: 9px; color: #252a3d; line-height: 1.8;
  background: #12151d;
  border-top: 1px solid #1a1e2a;
}

/* ── Map ─────────────────────────────────────────────────────────────────── */
#map { flex: 1; height: 100%; }

/* Leaflet overrides */
.leaflet-control-zoom { display: none; }
.leaflet-control-attribution {
  background: rgba(13,15,20,.85) !important;
  color: #3a4060 !important; font-size: 10px !important;
}
.leaflet-control-attribution a { color: #4a5a90 !important; }

/* Grid number labels */
.grid-num {
  background: #1e2c5a; border: 1.5px solid #3b6ffb;
  border-radius: 4px; color: #7b96ff;
  font-size: 9px; font-weight: 700; font-family: Inter, sans-serif;
  padding: 1px 5px; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,.6);
  pointer-events: none;
}

/* Commune tooltips */
.commune-tooltip {
  background: rgba(18,21,29,.92) !important;
  border: 1px solid #252a3d !important;
  color: #c0ccf0 !important;
  font-family: Inter, sans-serif !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.5) !important;
}
.commune-tooltip.main-tip { border-color: #e03c5a !important; }

/* Scrollbar */
aside::-webkit-scrollbar { width: 4px; }
aside::-webkit-scrollbar-track { background: transparent; }
aside::-webkit-scrollbar-thumb { background: #1e2230; border-radius: 4px; }
#neighbor-list::-webkit-scrollbar { width: 3px; }
#neighbor-list::-webkit-scrollbar-thumb { background: #1e2230; border-radius: 3px; }

/* Deed drag-and-drop zone */
#deed-dropzone {
  display: block;
  border: 1.5px dashed #252a3d;
  border-radius: 8px;
  padding: 14px 8px;
  text-align: center;
  transition: border-color .2s, background .2s;
  background: rgba(59,111,251,.04);
}
#deed-dropzone.drag-over {
  border-color: #3b6ffb;
  background: rgba(59,111,251,.12);
}

.deed-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 5px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  transition: background .15s;
  font-size: 10px;
  color: #8090b0;
}
.deed-row:hover { background: rgba(59,111,251,.12); color: #c0d0ff; }
.deed-row .deed-main { flex: 1; min-width: 0; }
.deed-row .deed-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d4ddff; }
.deed-row .deed-meta { margin-top: 2px; color: #66769c; font-size: 9px; }
.deed-row .deed-badge { background: #22c55e; color: #fff; border-radius: 3px; padding: 1px 5px; font-size: 9px; font-weight: 700; flex-shrink: 0; }
.deed-tags,
.deed-meta-row,
.deed-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.deed-tags { margin-top: 5px; }
.deed-tag,
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.deed-tag {
  background: rgba(59,111,251,.12);
  color: #9fb7ff;
  border: 1px solid rgba(59,111,251,.18);
}
.deed-tag.donation {
  background: rgba(37,99,235,.16);
  color: #9ec5ff;
  border-color: rgba(96,165,250,.3);
}
.deed-tag.warn {
  background: rgba(245,158,11,.14);
  color: #f7c66b;
  border-color: rgba(245,158,11,.22);
}
.deed-tag.ok {
  background: rgba(34,197,94,.14);
  color: #7ee2a5;
  border-color: rgba(34,197,94,.22);
}

.deed-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.deed-kpi {
  background: #171b27;
  border: 1px solid #1e2230;
  border-radius: 7px;
  padding: 7px 8px;
}
.deed-kpi-value {
  font-size: 17px;
  font-weight: 700;
  color: #dbe5ff;
  line-height: 1;
}
.deed-kpi-label {
  margin-top: 4px;
  font-size: 8px;
  color: #5e6a8f;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.deed-meta-row,
.deed-legend {
  margin-top: 8px;
}
.legend-chip {
  background: rgba(255,255,255,.04);
  color: #9caad0;
  border: 1px solid rgba(255,255,255,.05);
  text-transform: none;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-donation { background: #2563eb; }
.legend-owned { background: #22c55e; }
.legend-warn { background: #f59e0b; }
.legend-other { background: #ef4444; }

.parcel-detail {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #171b27;
  border: 1px solid #1e2230;
}
.parcel-detail-empty {
  font-size: 10px;
  color: #6f7c9e;
  line-height: 1.5;
}
.parcel-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.parcel-detail h4 {
  font-size: 13px;
  color: #eef3ff;
}
.parcel-detail-sub {
  margin-top: 2px;
  font-size: 10px;
  color: #6f7c9e;
}
.parcel-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 9px;
}
.parcel-detail-cell {
  background: rgba(255,255,255,.03);
  border-radius: 6px;
  padding: 6px 7px;
}
.parcel-detail-cell span {
  display: block;
  font-size: 8px;
  color: #5e6a8f;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.parcel-detail-cell strong {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: #d7e2ff;
}
.parcel-sources {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
}
.parcel-source {
  padding-top: 7px;
  border-top: 1px solid #202638;
}
.parcel-source:first-child {
  padding-top: 0;
  border-top: none;
}
.parcel-source-title {
  font-size: 10px;
  color: #d7e2ff;
}
.parcel-source-meta {
  margin-top: 2px;
  font-size: 9px;
  color: #7281a8;
}
.parcel-source-fragment {
  margin-top: 4px;
  font-size: 9px;
  color: #98a6cb;
  line-height: 1.4;
}

/* Parcel ownership tooltip */
.parcel-tip {
  background: rgba(13,15,20,.92) !important;
  border: 1px solid #252a3d !important;
  color: #c0ccf0 !important;
  font-family: Inter, sans-serif !important;
  font-size: 11px !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.5) !important;
  padding: 5px 8px !important;
  pointer-events: none;
}
