/* ============================================================
   THE GREEN WALL OF ALCALA — M&E Tool
   ============================================================ */
:root {
  --green-900: #14351f;
  --green-800: #1b4332;
  --green-700: #23633b;
  --green-600: #2f9e44;
  --green-500: #40c057;
  --green-400: #69db7c;
  --green-100: #e6f6ea;
  --green-50:  #f4faf4;
  --amber:     #f59f00;
  --red:       #e03131;
  --ink:       #1f2d23;
  --muted:     #6b7f70;
  --line:      #dde8de;
  --bg:        #eef3ee;
  --card:      #ffffff;
  --radius:    14px;
  --shadow:    0 4px 18px rgba(20, 53, 31, .07);
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.45;
}
a { color: var(--green-600); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--green-50); padding: 1px 5px; border-radius: 4px; font-size: .85em; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(178deg, var(--green-900) 0%, var(--green-800) 55%, #173f2a 100%);
  color: #d9ecdd;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  flex-shrink: 0;
  z-index: 50;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .92rem; letter-spacing: .06em; color: #fff; }
.brand-text span { font-size: .92rem; letter-spacing: .14em; color: var(--green-400); font-weight: 700; }
.brand-text em { font-style: normal; font-size: .66rem; color: #9fc7a8; margin-top: 3px; letter-spacing: .03em; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  color: #cfe6d4; font-weight: 500; font-size: .93rem;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--green-600); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.nav-ico { width: 20px; text-align: center; font-size: 1rem; opacity: .95; }

.sidebar-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.09); font-size: .78rem; color: #9fc7a8; }
.lgu-chip { display: inline-block; background: rgba(105,219,124,.15); color: var(--green-400); border: 1px solid rgba(105,219,124,.35); padding: 3px 8px; border-radius: 999px; font-weight: 600; font-size: .72rem; }
.prov { margin-top: 6px; }
.sys-date { margin-top: 2px; opacity: .8; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 13px 24px; position: sticky; top: 0; z-index: 40;
}
.menu-btn { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--green-800); }
.topbar-title { font-weight: 700; font-size: 1.02rem; color: var(--green-900); display: flex; flex-direction: column; }
.crumb { font-weight: 400; font-size: .74rem; color: var(--muted); letter-spacing: .02em; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.content { padding: 22px 24px 40px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: .9rem; padding: 9px 16px;
  font-family: inherit; transition: filter .12s, background .12s;
  text-decoration: none !important;
}
.btn:hover { filter: brightness(1.05); }
.btn-primary { background: var(--green-600); color: #fff; }
.btn-outline { background: #fff; color: var(--green-700); border: 1.5px solid var(--green-600); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-xs { padding: 4px 9px; font-size: .74rem; border-radius: 7px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--muted); padding: 4px 6px; }
.icon-btn:hover { color: var(--red); }
.link { font-size: .84rem; font-weight: 600; }

.seg { display: inline-flex; background: var(--green-50); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg-btn { border: none; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: .84rem; color: var(--muted); font-family: inherit; }
.seg-btn.active { background: var(--green-600); color: #fff; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 18px 16px; display: flex; gap: 14px; position: relative; overflow: hidden;
  border: 1px solid rgba(255,255,255,.8);
}
.kpi-ico { font-size: 1.7rem; width: 52px; height: 52px; border-radius: 13px; display: flex; align-items: center; justify-content: center; background: var(--green-100); flex-shrink: 0; }
.kpi-value { font-size: 1.85rem; font-weight: 800; color: var(--green-800); line-height: 1.1; }
.kpi-unit { font-size: .95rem; font-weight: 700; color: var(--green-600); margin-left: 2px; }
.kpi-label { font-size: .8rem; font-weight: 700; color: var(--ink); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-sub { font-size: .76rem; color: var(--muted); margin-top: 3px; }
.kpi-bar { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: var(--green-100); }
.kpi-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--green-500), var(--green-600)); }
.kpi-trees .kpi-ico { background: #e7f5e9; }
.kpi-survival .kpi-ico { background: #d3f9d8; }
.kpi-area .kpi-ico { background: #fff3bf; }
.kpi-moa .kpi-ico { background: #e7f5ff; }

/* ---------- Cards / grids ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-bottom { grid-template-columns: 1.4fr 1fr; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; border: 1px solid rgba(221,232,222,.7);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: .98rem; color: var(--green-900); }
.card-accent { background: linear-gradient(150deg, var(--green-800), var(--green-700)); color: #e8f5ea; border: none; }
.card-accent h3 { color: #fff !important; }
.card-accent .link { color: var(--green-400); }
.accent-lead { font-size: .88rem; color: #cbe8d1; line-height: 1.55; }

.chip {
  background: var(--green-50); color: var(--green-700); border: 1px solid var(--line);
  font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.chip-green { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.chip-amber { background: #fff3bf; color: #99660a; border-color: #ffe066; }

.chart-box { position: relative; height: 240px; }
.chart-box-sm { height: 210px; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.qa {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  color: #fff; border-radius: 9px; padding: 10px 10px; font-size: .8rem; font-weight: 600;
  cursor: pointer; text-align: left; font-family: inherit;
}
.qa:hover { background: rgba(255,255,255,.2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table-scroll { max-height: 480px; overflow-y: auto; }
.hist-scroll { max-height: 430px; }
.session-scroll { max-height: 520px; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th {
  text-align: left; padding: 9px 10px; background: var(--green-50);
  color: var(--green-800); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; border-bottom: 2px solid var(--line);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
.table td { padding: 8px 10px; border-bottom: 1px solid #edf3ed; vertical-align: middle; }
.table-hover tbody tr:hover td { background: var(--green-50); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.ok { color: var(--green-600); font-weight: 700; }
.warn { color: var(--amber); font-weight: 700; }

.status {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
}
.status-alive { background: #d3f9d8; color: #2b8a3e; }
.status-dead { background: #ffe3e3; color: #c92a2a; }
.status-damaged { background: #fff3bf; color: #99660a; }
.status-lost { background: #e9ecef; color: #495057; }

.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions form { margin: 0; }

/* ---------- Filter bar / forms ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin-bottom: 16px; padding: 14px 16px;
}
.filter-bar label, .stack-form label, .inline-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .76rem; font-weight: 700; color: var(--green-800);
  text-transform: uppercase; letter-spacing: .03em;
}
input, select, textarea {
  font-family: inherit; font-size: .9rem; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(64,192,87,.15); }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hidden-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--green-50); padding: 10px; border-radius: 9px; margin-top: 10px;
  border: 1px dashed var(--green-500);
}
.hidden-form[hidden] { display: none; }
.hidden-form input[type="file"] { font-size: .8rem; }
.hidden-form label.small { text-transform: none; flex: 1; min-width: 140px; }

/* ---------- Map page ---------- */
.map-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; height: calc(100vh - 120px); min-height: 560px; }
.map-panel { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.map-el { width: 100%; height: 100%; background: #dfe8df; }
.map-legend {
  position: absolute; bottom: 14px; left: 14px; z-index: 1000;
  background: rgba(255,255,255,.95); border-radius: 10px; padding: 8px 12px;
  display: flex; gap: 14px; font-size: .75rem; font-weight: 600;
  box-shadow: 0 3px 10px rgba(0,0,0,.12); flex-wrap: wrap;
  max-width: calc(100% - 430px); /* leave room for the GPS bar on the right */
}
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg-poly { background: rgba(47,158,68,.25); border: 2px solid var(--green-600); }
.lg-alive { background: var(--green-500); border-radius: 50% !important; }
.lg-dead { background: var(--red); border-radius: 50% !important; }
.lg-damaged { background: var(--amber); border-radius: 50% !important; }
.map-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(27,67,50,.88); color: #e8f5ea; font-size: .78rem;
  padding: 7px 16px; border-radius: 999px; z-index: 1000; white-space: nowrap;
  max-width: calc(100% - 200px); overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; /* never block the layer control / map clicks */
}
.map-side { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; max-height: calc(100vh - 120px); padding-right: 2px; }
.side-card { padding: 14px 16px; }
.site-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.site-item {
  text-align: left; background: var(--green-50); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 10px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; gap: 2px;
}
.site-item:hover { border-color: var(--green-500); background: #fff; }
.site-item strong { font-size: .84rem; color: var(--green-900); }
.site-item span { font-size: .74rem; color: var(--muted); }
.site-item em { font-style: normal; font-weight: 700; }
.site-item em.ok { color: var(--green-600); }
.site-item em.warn { color: var(--amber); }
.upload-msg { font-size: .8rem; margin-top: 8px; min-height: 1em; }
.upload-msg.err { color: var(--red); }
.upload-msg.good { color: var(--green-600); font-weight: 600; }
.sd-body { font-size: .86rem; }
.sd-body dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 8px 0; }
.sd-body dt { font-weight: 700; color: var(--green-800); font-size: .78rem; }
.sd-body dd { margin: 0; }
.sd-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Sites / parcels ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.parcel-card { display: flex; flex-direction: column; gap: 10px; }
.parcel-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.parcel-top h3 { margin: 0 0 2px; font-size: 1rem; color: var(--green-900); }
.parcel-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; background: var(--green-50); border-radius: 10px; padding: 10px 6px; }
.parcel-stats b { display: block; font-size: 1.05rem; color: var(--green-700); }
.parcel-stats span { font-size: .64rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.parcel-meta { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 4px 0; font-size: .84rem; }
.parcel-meta dt { font-weight: 700; color: var(--green-800); font-size: .76rem; }
.parcel-meta dd { margin: 0; }
.parcel-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; }
.parcel-add { background: linear-gradient(160deg, #f4faf4, #fff); border: 1.5px dashed var(--green-500); }

/* ---------- Monitoring ---------- */
.session-summary {
  margin-top: 12px; padding: 10px 14px; background: var(--green-50);
  border-radius: 10px; font-size: .86rem; border: 1px solid var(--line);
}
.head-actions { display: flex; gap: 8px; }
.hist-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hist-filters select, .hist-filters input { padding: 5px 7px; font-size: .8rem; }
.status-select { padding: 4px 6px; font-size: .8rem; border-radius: 6px; }
.cond-select { padding: 4px 6px; font-size: .8rem; border-radius: 6px; max-width: 150px; }
.note-input { padding: 4px 8px; font-size: .8rem; border-radius: 6px; width: 160px; }
.h-input { width: 74px; padding: 4px 6px; font-size: .8rem; }

/* ---------- Reports ---------- */
.grid-reports { grid-template-columns: 1.1fr .9fr; }
.feature-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; font-size: .88rem; }
.feature-list li { padding: 8px 10px; background: var(--green-50); border-radius: 8px; border: 1px solid var(--line); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,35,20,.55);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
  padding: 20px; backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  padding: 20px 22px; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-sm { max-width: 440px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; color: var(--green-900); font-size: 1.05rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 3000;
  background: var(--green-800); color: #fff; padding: 12px 18px;
  border-radius: 10px; font-weight: 600; font-size: .88rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .25s, transform .25s; max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--red); }

/* ---------- Empty ---------- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 3rem; }
.empty-state h2 { color: var(--green-800); }
.empty-state .btn { margin-top: 12px; }

/* ---------- Bulk-enrollment wizard ---------- */
.modal-wide { max-width: 720px; }
.wizard-steps {
  display: flex; gap: 8px; list-style: none; margin: 0 0 14px;
  padding: 0; font-size: .78rem; font-weight: 700; color: var(--muted);
}
.wizard-steps li {
  flex: 1; text-align: center; padding: 7px 6px; border-radius: 8px;
  background: #eef3ee; border-bottom: 3px solid transparent;
}
.wizard-steps li.active { background: #e3f2e8; color: var(--green-800); border-bottom-color: var(--green-600); }
.wizard-steps li.done { background: var(--green-600); color: #fff; }
.hint-banner {
  background: #fff8e1; border: 1px solid #f0e0a0; color: #6b5b12;
  padding: 8px 12px; border-radius: 8px; font-size: .82rem; margin: 0 0 12px;
}
.mix-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.mix-row {
  display: flex; gap: 10px; align-items: end;
  background: #f6faf6; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px;
}
.mix-row label { display: flex; flex-direction: column; gap: 3px; font-size: .75rem; font-weight: 700; color: var(--muted); flex: 1; }
.mix-row input, .mix-row select { margin: 0; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.enroll-map {
  height: 320px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); margin-bottom: 8px;
}
.confirm-summary { background: #f6faf6; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.confirm-summary h4 { margin: 0 0 8px; color: var(--green-800); }
.confirm-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.confirm-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 10px 4px 0; width: 34%; }
.confirm-table td { padding: 4px 0; }
.enroll-done { text-align: center; padding: 18px 8px; }
.enroll-done .done-icon { font-size: 2.6rem; }
.enroll-done h4 { color: var(--green-800); margin: 6px 0; }
.enroll-done code { background: #eef3ee; padding: 2px 6px; border-radius: 5px; }

/* ---------- Parcel geotag verification chips ---------- */
.parcel-verify { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.pv-chip {
  font-size: .7rem; font-weight: 700; padding: 3px 8px;
  border-radius: 999px; background: #eef3ee; color: var(--muted);
}
.pv-verified { background: #e3f2e8; color: var(--green-800); }
.pv-unverified { background: #f4f4f4; color: #888; }
.pv-bulk { background: #e8f1fd; color: #245a9e; }
.pv-badge {
  font-size: .7rem; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: linear-gradient(135deg, #f6e3a1, #e8c96a); color: #5a4708;
  border: 1px solid #d4b44a;
}
.parcel-verify.audit-ready .pv-verified { box-shadow: 0 0 0 2px rgba(34,197,94,.25); }

/* ---------- Leaflet popup polish ---------- */
.leaflet-popup-content { margin: 10px 14px; font-size: .85rem; }
.leaflet-popup-content h4 { margin: 0 0 6px; color: var(--green-800); font-size: .92rem; }
.leaflet-popup-content table { border-collapse: collapse; }
.leaflet-popup-content td { padding: 2px 6px 2px 0; }
.leaflet-popup-content .pp-actions { margin-top: 7px; display: flex; gap: 6px; flex-wrap: wrap; }
.pp-btn {
  display: inline-block; background: var(--green-600); color: #fff !important;
  padding: 4px 9px; border-radius: 6px; font-size: .74rem; font-weight: 700;
  text-decoration: none !important; border: none; cursor: pointer;
}
.pp-btn-ghost { background: transparent; color: var(--green-800) !important; border: 1px solid var(--green-600); }
.tree-dot { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.addtree-mode .leaflet-crosshair, .addtree-mode .leaflet-interactive { cursor: crosshair; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .map-layout { grid-template-columns: 1fr; height: auto; }
  .map-el { height: 480px; }
  .map-side { max-height: none; }
}
@media (max-width: 900px) {
  .grid-2, .grid-bottom, .grid-reports { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -280px; transition: left .25s; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  .sidebar.open { left: 0; }
  .menu-btn { display: block; }
  .content { padding: 16px 14px 30px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}

/* ============================================================
   Feature pack: roles · audit · MOA alerts · QR tags
   ============================================================ */

/* Login redirect target */
.topbar-right .user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green-50); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px 4px 5px;
}
.user-av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--green-600); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.1; }
.user-meta b { font-size: .78rem; color: var(--green-900); }

/* Role badges */
.role-badge {
  display: inline-block; font-size: .64rem; font-weight: 800;
  padding: 2px 7px; border-radius: 999px; letter-spacing: .04em;
  text-transform: uppercase; font-style: normal;
}
.role-admin { background: #d3f9d8; color: #2b8a3e; border: 1px solid #b2f2bb; }
.role-moe { background: #d0ebff; color: #1864ab; border: 1px solid #a5d8ff; }
.role-caretaker { background: #fff3bf; color: #99660a; border: 1px solid #ffe066; }
.role-area_monitor { background: #e3fafc; color: #0b7285; border: 1px solid #96f2d7; }
.role-viewer { background: #e9ecef; color: #495057; border: 1px solid #dee2e6; }

/* Alert bar (dashboard) */
.alert-bar {
  display: flex; align-items: center; gap: 10px;
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
  font-size: .9rem; font-weight: 500;
  border: 1px solid transparent; animation: slideDown .3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.alert-danger { background: #fff5f5; border-color: #ffc9c9; color: #c92a2a; }
.alert-warn { background: #fff9db; border-color: #ffe066; color: #99660a; }
.alert-ico { font-size: 1.15rem; }
.alert-link {
  margin-left: auto; font-weight: 700; white-space: nowrap;
  text-decoration: underline !important;
}
.alert-danger .alert-link { color: #c92a2a; }
.alert-warn .alert-link { color: #99660a; }

/* MOA expiry states (sites page) */
.moa-state {
  display: inline-block; font-size: .74rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin-top: 3px;
}
.ms-expired { background: #ffe3e3; color: #c92a2a; border: 1px solid #ffc9c9; }
.ms-expiring { background: #fff3bf; color: #99660a; border: 1px solid #ffe066; }
.ms-valid { background: #d3f9d8; color: #2b8a3e; border: 1px solid #b2f2bb; }
.ms-unknown { background: #e9ecef; color: #495057; }

/* Audit trail badges */
.nowrap { white-space: nowrap; }
.audit-badge {
  display: inline-block; font-size: .68rem; font-weight: 800;
  padding: 3px 8px; border-radius: 6px; font-family: ui-monospace, monospace;
  background: var(--green-50); color: var(--green-700);
  border: 1px solid var(--line); white-space: nowrap;
}
.ab-auth { background: #d0ebff; color: #1864ab; border-color: #a5d8ff; }
.ab-user { background: #e5dbff; color: #5f3dc4; border-color: #d0bfff; }
.ab-site { background: #fff3bf; color: #99660a; border-color: #ffe066; }
.ab-tree { background: #d3f9d8; color: #2b8a3e; border-color: #b2f2bb; }
.ab-report { background: #ffe8cc; color: #d9480f; border-color: #ffd8a8; }
.ab-monitoring { background: #c5f6fa; color: #0b7285; border-color: #99e9f2; }
.ab-export { background: #e9ecef; color: #495057; border-color: #dee2e6; }

/* QR tag modal */
.qr-modal-body { display: flex; flex-direction: column; gap: 10px; }
.qr-holder {
  display: flex; justify-content: center; padding: 14px;
  background: #fff; border: 1.5px dashed var(--green-500);
  border-radius: 12px;
}
.qr-holder svg { width: 210px; height: 210px; }
.qr-meta { text-align: center; font-size: .88rem; line-height: 1.5; }
.qr-meta .tag-code {
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 800; font-size: 1.05rem; color: var(--green-900);
}
.qr-meta .tag-status {
  display: inline-block; font-size: .68rem; font-weight: 800;
  padding: 2px 9px; border-radius: 999px; text-transform: uppercase;
}
.tag-status.alive { background: #d3f9d8; color: #2b8a3e; }
.tag-status.dead { background: #ffe3e3; color: #c92a2a; }
.tag-status.damaged { background: #fff3bf; color: #99660a; }
.tag-status.lost { background: #e9ecef; color: #495057; }

/* ============================================================
   MOA Generator
   ============================================================ */
.ph-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  max-height: 340px; overflow-y: auto; padding: 4px 2px;
}
.ph-field {
  display: flex; flex-direction: column; gap: 4px;
  background: #fffcf0; border: 1.5px solid #ffe066;
  border-radius: 9px; padding: 8px 10px;
  font-size: .72rem; font-weight: 800; color: #99660a;
  text-transform: uppercase; letter-spacing: .03em;
}
.ph-field input {
  font-size: .92rem; font-weight: 400; text-transform: none;
  color: var(--ink); letter-spacing: normal;
}
.ph-field.filled {
  background: var(--green-50); border-color: var(--green-500);
}
.ph-field.filled > span { color: var(--green-700); }

.ph-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0; }
.ph-chip {
  display: inline-block; background: var(--green-50);
  border: 1px solid var(--green-500); color: var(--green-700);
  font-family: ui-monospace, Consolas, monospace;
  font-size: .7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 999px;
}

.tpl-list { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.tpl-item {
  background: var(--green-50); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
.tpl-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tpl-head strong { color: var(--green-900); font-size: .9rem; }
.tpl-src { font-size: .68rem; font-weight: 800; color: var(--muted); letter-spacing: .05em; }
.tpl-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: .72rem; color: var(--muted); margin-top: 4px;
}

@media (max-width: 900px) {
  .ph-grid { grid-template-columns: 1fr; }
}

/* ── Map: Google basemap control + live GPS tracking ───────────── */
.leaflet-control-layers {
  border-radius: 10px !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 3px 12px rgba(0,0,0,.14) !important;
  font-size: .8rem;
}
.leaflet-control-layers-expanded label { font-weight: 600; padding: 2px 0; }

.gps-bar {
  position: absolute; bottom: 14px; right: 14px; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.95); border-radius: 999px;
  padding: 6px 10px; box-shadow: 0 3px 10px rgba(0,0,0,.12);
}
.gps-btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 700;
  font-size: .75rem; padding: 6px 12px; border-radius: 999px;
  background: var(--green-600, #2f9e44); color: #fff;
  transition: background .15s ease;
}
.gps-btn:hover { filter: brightness(1.06); }
.gps-btn.gps-on {
  background: #1c7ed6;
  animation: gps-btn-glow 1.6s ease-in-out infinite;
}
@keyframes gps-btn-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(28,126,214,.45); }
  50%      { box-shadow: 0 0 0 6px rgba(28,126,214,0); }
}
.gps-status {
  font-size: .72rem; font-weight: 600; color: #37424a;
  font-variant-numeric: tabular-nums; max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gps-status[data-on="1"] { color: #1c7ed6; }
.gps-follow {
  font-size: .7rem; font-weight: 700; color: #556;
  display: flex; align-items: center; gap: 3px; cursor: pointer;
  user-select: none;
}
.gps-follow input { accent-color: #1c7ed6; margin: 0; }

/* pulsing current-position marker */
.gps-pulse-wrap { background: transparent; border: none; }
.gps-pulse {
  display: block; width: 28px; height: 28px; position: relative;
}
.gps-pulse::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: rgba(28,126,214,.35);
  animation: gps-ring 1.8s ease-out infinite;
}
.gps-dot {
  position: absolute; left: 7px; top: 7px; width: 14px; height: 14px;
  border-radius: 50%; background: #1c7ed6;
  border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.35);
}
@keyframes gps-ring {
  0%   { transform: scale(.5); opacity: .9; }
  100% { transform: scale(1.9); opacity: 0; }
}

@media (max-width: 900px) {
  .gps-bar { bottom: auto; top: 52px; right: 10px; flex-wrap: wrap; max-width: 220px; border-radius: 14px; }
  .gps-status { max-width: 140px; }
}
