.hidden {
  display: none !important;
}

.close-btn {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 8px;
  padding: 0 8px;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.15s;
}
.close-btn:hover {
  background: rgba(220,38,38,0.08);
}
:root{
  --bg: #efe9e3;
  --panel: #f6f3ef;
  --ink: #1f2a37;
  --muted: #6b7280;
  --bar: #28435c;
  --border: rgba(0,0,0,0.10);
  --shadow: 0 10px 30px rgba(0,0,0,0.12);
  --radius: 12px;
}

*{ box-sizing: border-box; }
html, body{ height:100%; margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color:var(--ink); background: var(--bg); }

.topbar{
  height: 56px;
  background: var(--bar);
  color: white;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.brand{ display:flex; align-items:center; gap:10px; }
.logo{ width:30px; height:30px; display:grid; place-items:center; background: rgba(255,255,255,0.12); border-radius: 8px; }
.title{ font-weight:700; letter-spacing: 0.2px; }

.topbar-actions{ display:flex; gap:10px; align-items:center; }
.search{
  width: 320px;
  max-width: 40vw;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.16);
  color: white;
  outline: none;
}
.search::placeholder{ color: rgba(255,255,255,0.75); }

.icon-btn{
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.16);
  color: white;
  height: 36px;
  width: 42px;
  border-radius: 10px;
  cursor:pointer;
}
.icon-btn:hover{ background: rgba(255,255,255,0.22); }

.layout{
  display:grid;
  grid-template-columns: 320px 1fr 300px;
  gap: 12px;
  padding: 12px;
  height: calc(100% - 56px - 290px);
  min-height: 420px;
  position: relative;
  z-index: 0;
}

/* Make the main layout fill the available space when the bottom panel is hidden */
body.cut-panel-hidden .layout {
  height: calc(100% - 56px);
}

.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.panel-block{
  padding: 12px 12px 14px;
  border-bottom: 1px solid var(--border);
}
.panel-block:last-child{ border-bottom: none; }

.panel h2{
  margin: 2px 0 10px;
  font-size: 16px;
}

.legend{ display:flex; flex-direction:column; gap:10px; }
.legend-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.55);
}

.swatch{
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(0,0,0,0.15);
}
.swatch-model{ background: rgba(236,72,153,0.35); }
.swatch-bh{ background: rgba(37,99,235,0.25); }

.model-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.model-chip{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
}
.model-chip b{ font-size: 13px; }
.model-pill{
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.06);
  color: var(--muted);
}

.toolbox{ display:flex; gap:10px; flex-wrap:wrap; }

.btn{
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  cursor:pointer;
}
.btn:hover{ filter: brightness(0.98); }
.btn.primary{
  background: #0f2f4a;
  color: white;
  border-color: rgba(255,255,255,0.12);
}

.hint{
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(15,47,74,0.06);
  border: 1px solid rgba(15,47,74,0.12);
  border-radius: 10px;
  font-size: 13px;
}

.small{ font-size: 13px; }
.muted{ color: var(--muted); }

.map-wrap{
  position:relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible; /* was hidden, now visible to allow Leaflet overlays to extend */
  z-index: 1;
}

#map{ width:100%; height:100%; z-index: 2; }

.status-pill{
  position:absolute;
  left: 12px;
  bottom: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.section-panel{
  height: 290px;
  margin: 0 12px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  width: 100vw;
  max-width: 100vw;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 10;
}

.section-panel.hidden {
  display: none !important;
}

body.cut-panel-hidden .section-panel {
  display: none !important;
}

.section-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.35);
}
.section-title{ font-weight: 800; }
.section-subtitle{ font-size: 13px; margin-top: 2px; }
.section-actions{ display:flex; gap:10px; }

.section-body{
  padding: 10px 12px 12px;
  height: 100%;
  background: white;
}
#sectionCanvas{
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(0,0,0,0.20);
  border-radius: 10px;
}

/* Borehole popup log */
.bh-popup h3{
  margin: 0 0 8px;
  font-size: 16px;
}
.bh-meta{
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.log{
  border-top: 1px solid rgba(0,0,0,0.12);
  padding-top: 8px;
  display:grid;
  grid-template-columns: 60px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}
.depth{
  color: var(--muted);
  text-align:right;
  padding-right: 6px;
}
.layer{
  border-radius: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(0,0,0,0.10);
}
.layer small{
  display:block;
  color: rgba(0,0,0,0.55);
  margin-top: 2px;
}

/* Responsive */
@media (max-width: 1100px){
  .layout{ grid-template-columns: 300px 1fr; grid-template-rows: 1fr auto; }
  .panel.right{ display:none; }
}
@media (max-width: 820px){
  .layout{ grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; height:auto; }
  .panel.left{ order: 1; }
  .map-wrap{ order: 2; height: 420px; }
  .section-panel{ height: 260px; }
  .search{ width: 180px; }
}
