:root {
  --bg: #f5f7f2;
  --surface: #ffffff;
  --surface-alt: #ebf1e5;
  --text: #1f2a24;
  --muted: #5d6c62;
  --accent: #2f7f5f;
  --accent-dark: #235f47;
  --danger: #b33737;
  --border: #d4ded1;
  --shadow: 0 10px 24px rgba(23, 38, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(47, 127, 95, 0.11), transparent 35%),
    radial-gradient(circle at 100% 30%, rgba(146, 175, 84, 0.1), transparent 30%),
    var(--bg);
  font-family: "Segoe UI", "Noto Sans", sans-serif;
  line-height: 1.45;
}

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.shell {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
  background: rgba(245, 247, 242, 0.9);
  border-bottom: 1px solid var(--border);
}

.site-header h1 a {
  text-decoration: none;
  color: var(--accent-dark);
}


.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
}

nav a {
  text-decoration: none;
  color: var(--accent-dark);
  margin-left: 1rem;
  font-weight: 600;
}

main.shell {
  padding: 1.2rem 0 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.two-cols {
  grid-template-columns: 1.5fr 1fr;
}

.stack {
  display: grid;
  gap: 0.65rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.autocomplete-wrap {
  display: grid;
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.3rem);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
  z-index: 40;
  display: none;
}

.autocomplete-dropdown.is-open {
  display: block;
}

.autocomplete-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 500;
}

.autocomplete-item:last-child {
  border-bottom: 0;
}

.autocomplete-item:hover,
.autocomplete-item.is-active {
  background: var(--surface-alt);
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}

button,
.import-btn {
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
}

button:hover,
.import-btn:hover {
  background: var(--accent-dark);
}

button.danger {
  background: var(--danger);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.alert {
  color: var(--danger);
  font-weight: 600;
}

#map {
  width: 100%;
  height: 58vh;
  /* min-height: 360px; */
  border-radius: 12px;
  overflow: hidden;
}

.leaflet-top {
    top: 5.7em;
}

.family-pin-wrapper {
  background: transparent;
  border: 0;
}

.family-pin {
  display: block;
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--pin-color, #2f7f5f);
  border: 1px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.family-pin::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  top: 5px;
  left: 5px;
}

.branch-legend {
  min-width: 190px;
  max-width: 260px;
  max-height: 230px;
  overflow: auto;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.branch-legend h4 {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
  color: var(--text);
}

.branch-legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.branch-legend li {
  display: grid;
  grid-template-columns: 11px 1fr;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
}

.branch-legend .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--dot-color, #2f7f5f);
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.fullscreen-map-page .branch-legend {
  background: rgba(255, 255, 255, 0.88);
}

.stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.stats-list li {
  background: var(--surface-alt);
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.branch-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.branch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 0.55rem;
  vertical-align: top;
}

.actions {
  display: flex;
  gap: 0.35rem;
}

.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-wrap .card {
  width: min(460px, 92vw);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 0.9rem 0 1.2rem;
  color: var(--muted);
  text-align: center;
}

.ghost {
  background: #fff;
  color: var(--accent-dark);
  border: 1px solid var(--border);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
}

.map-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.section-card p {
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.ghost:hover {
  background: var(--surface-alt);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.modal.is-open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 24, 20, 0.45);
}

.modal-panel {
  position: relative;
  margin: 4vh auto;
  width: min(760px, 92vw);
  max-height: 92vh;
  overflow: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.fullscreen-map-page {
  margin: 0;
  background: #0f1a14;
}

.fullscreen-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  color: #eff6f0;
  background: rgba(14, 24, 19, 0.72);
  backdrop-filter: blur(6px);
}

.fullscreen-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.fullscreen-topbar .link-btn,
.fullscreen-topbar button {
  background: rgba(255, 255, 255, 0.12);
  color: #f3fbf5;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.fullscreen-topbar .link-btn:hover,
.fullscreen-topbar button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.map-fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
}

#edit-feedback:empty {
  display: none;
}

@media (max-width: 880px) {
  .two-cols {
    grid-template-columns: 1fr;
  }

  .header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  nav a {
    margin-left: 0;
    margin-right: 0.8rem;
  }

  #map {
    height: 52vh;
    /* min-height: 320px; */
  }
}
