*{box-sizing:border-box}

body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
  background:#f4f6f8;
  color:#17202a;
}

header{
  position:sticky;
  top:0;
  z-index:20;
  background:#123d61;
  color:#fff;
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

h1{font-size:21px;margin:0 0 2px}
header small{opacity:.85}

.headActions{
  display:flex;
  gap:10px;
  align-items:center;
}

.headActions a,header a{color:white}

.headActions button{
  width:auto;
  margin:0;
  padding:8px 12px;
}

.smallBtn{
  border:1px solid #ffffff55;
  background:#ffffff16;
  color:#fff;
  padding:8px 10px;
  border-radius:8px;
  text-decoration:none;
  font:inherit;
  cursor:pointer;
}

main{
  max-width:1400px;
  margin:auto;
  padding:14px 18px 30px;
}

.tabs{
  display:flex;
  background:#fff;
  border-radius:10px;
  padding:4px;
  margin-bottom:12px;
  box-shadow:0 1px 5px #0001;
}

.tab{
  flex:1;
  border:0;
  background:transparent;
  padding:11px;
  font-weight:700;
  border-radius:8px;
}

.tab.active{
  background:#123d61;
  color:#fff;
}

.view{display:none}
.view.active{display:block}

.toolbar{
  display:grid;
  grid-template-columns:minmax(0,1fr) 220px;
  gap:10px;
  margin-bottom:10px;
}

.filters{
  display:grid;
  grid-template-columns:1fr 180px;
  gap:8px;
  margin-bottom:10px;
}

input,select,textarea{
  width:100%;
  padding:12px;
  border:1px solid #cbd3da;
  border-radius:8px;
  background:#fff;
  font:inherit;
}

textarea{min-height:90px}

#count{
  margin:6px 0 10px;
  font-size:15px;
  color:#52606d;
}

/* Three-column customer directory */
#siteList{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
  align-items:stretch;
}

/* Each site is a vertical card.
   This is intentionally NOT flex-row; the previous version
   squeezed the title, address and service into narrow columns. */
#siteList .card{
  width:100%;
  min-width:0;
  min-height:155px;
  margin:0;
  padding:20px;
  text-align:center;
  border:1px solid #e1e6ea;
  background:#fff;
  border-radius:12px;
  box-shadow:0 2px 8px #00000012;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  align-items:stretch;
  cursor:pointer;
  transition:box-shadow .15s ease,transform .15s ease;
}

#siteList .card:hover{
  box-shadow:0 5px 16px #00000018;
  transform:translateY(-1px);
}

#siteList .card h3{
  display:block;
  width:100%;
  margin:0 0 12px;
  padding-bottom:10px;
  font-size:18px;
  line-height:1.3;
  color:#123d61;
  text-align:center;
  border-bottom:1px solid #e6eaee;
}

#siteList .card > p{
  width:100%;
  margin:0;
  color:#5d6975;
  font-size:15px;
  line-height:1.45;
  text-align:center;
}

.chips{
  width:100%;
  margin-top:auto;
  padding-top:16px;
  text-align:center;
}

.chip{
  display:inline-block;
  background:#e8f1f8;
  color:#123d61;
  padding:5px 9px;
  border-radius:999px;
  font-size:12px;
  margin:0 5px 5px 0;
}

.chev{
  font-size:30px;
  color:#8795a1;
}

.service{
  border-top:1px solid #ddd;
  padding-top:10px;
  margin-top:14px;
}

.docbtn{
  width:auto;
  padding:8px 12px;
}

/* Site detail drawer */
.drawer{
  display:none;
  position:fixed;
  inset:0;
  background:#0008;
  z-index:50;
  padding:0;
}

.drawer.open{display:block}

.drawerInner{
  background:#fff;
  max-width:900px;
  margin:3vh auto;
  height:94vh;
  overflow:auto;
  border-radius:14px;
  position:relative;
  padding:18px;
}

.close{
  position:sticky;
  float:right;
  top:10px;
  margin:10px;
  z-index:5;
  border:0;
  background:#fff;
  border-radius:50%;
  width:38px;
  height:38px;
  font-size:26px;
  box-shadow:0 2px 8px #0003;
  cursor:pointer;
}

.detail{padding:18px}
.detail h2{margin:12px 0 5px}

.hero,.docImage{
  width:100%;
  max-height:430px;
  object-fit:contain;
  border-radius:10px;
  background:#eef1f4;
}

.doc{
  border-top:1px solid #dfe5ea;
  margin-top:20px;
  padding-top:16px;
}

.field{margin:12px 0}
.field b{color:#123d61}
.field p{white-space:pre-wrap;margin:4px 0}

.warning{
  background:#fff6df;
  padding:10px;
  border-radius:8px;
}

.actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:12px 0;
}

.primaryLink,.secondaryLink,.primary{
  display:inline-block;
  border:0;
  border-radius:8px;
  padding:11px 14px;
  text-decoration:none;
  font-weight:700;
  cursor:pointer;
}

.primaryLink,.primary{
  background:#123d61;
  color:#fff;
}

.secondaryLink{
  background:#e8eef3;
  color:#123d61;
}

/* Map */
#mapCanvas{
  height:68vh;
  border-radius:10px;
}

.notice,.muted{
  color:#65727e;
  font-size:13px;
  margin:8px 0;
}

/* Login */
.loginBody{
  min-height:100vh;
  display:grid;
  place-items:center;
  background:#123d61;
  padding:20px;
}

.loginCard{
  width:min(420px,100%);
  background:#fff;
  padding:28px;
  border-radius:14px;
  box-shadow:0 10px 30px #0003;
}

.loginCard h1{font-size:26px}
.loginCard label,.admin label{display:block;margin:12px 0;font-weight:600}
.loginCard .primary{width:100%;margin-top:8px}
.error{color:#b42318}

/* Admin */
.admin{max-width:850px}
.adminMain{max-width:850px;margin:auto}

.adminCard{
  background:#fff;
  padding:20px;
  border-radius:12px;
  margin:12px 0;
  box-shadow:0 1px 5px #0001;
}

.adminCard h2{margin-top:0}
.adminCard label{display:block;margin:12px 0;font-weight:600}

.adminCard input,.adminCard textarea,.adminCard select{
  width:100%;
  box-sizing:border-box;
  margin-top:5px;
  padding:10px;
}

.adminCard textarea{min-height:70px}

.grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:0 12px;
}

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

.success{
  background:#e7f7ed;
  color:#176b38;
  padding:12px;
  border-radius:8px;
  margin-bottom:10px;
}

details{margin:14px 0}
summary{cursor:pointer;font-weight:700}

/* Tablet */
@media(max-width:1000px){
  main{
    max-width:100%;
  }

  #siteList{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

/* Phone */
@media(max-width:600px){
  .toolbar,
  .filters,
  .grid,
  .row{
    grid-template-columns:1fr;
  }

  main{
    padding:10px;
  }

  #siteList{
    grid-template-columns:1fr;
    gap:12px;
  }

  #siteList .card{
    min-height:0;
  }

  .drawerInner{
    margin:0;
    height:100vh;
    border-radius:0;
  }

  header{
    padding-top:max(14px,env(safe-area-inset-top));
  }

  #mapCanvas{
    height:72vh;
  }
}
