/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,700;1,9..144,300;1,9..144,500&family=Syne:wght@400;500;600;700&display=swap');

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

:root {
  --sage-50:    #f3faf5;
  --sage-100:   #e2f2e8;
  --sage-200:   #c3dece;
  --sage-300:   #96c4aa;
  --leaf:       #2a7a4b;
  --leaf-hover: #1f5f38;
  --forest:     #162e1e;
  --body-text:  #253b2e;
  --muted:      #7a9882;
  --white:      #ffffff;
  --amber:      #d4883a;
  --red:        #c44040;
  --scanner-bg: #0c1c13;
  --radius:     14px;
  --radius-sm:  8px;
  --shadow-sm:  0 1px 4px rgba(22,46,30,0.07);
  --shadow:     0 4px 20px rgba(22,46,30,0.09);
  --shadow-lg:  0 8px 40px rgba(22,46,30,0.13);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background-color: var(--sage-50);
  background-image:
    radial-gradient(ellipse 60% 40% at 10% 90%, rgba(42,122,75,0.055) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 90% 10%, rgba(42,122,75,0.04) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--body-text);
  min-height: 100vh;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav {
  background: var(--forest);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
}

nav .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 1.3rem;
  color: var(--sage-100);
  text-decoration: none;
  letter-spacing: -0.01em;
  margin-right: 12px;
  flex-shrink: 0;
}

.nav-logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
  border-radius: 50%;
}

nav a:not(.brand) {
  font-family: 'Syne', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sage-300);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: color 0.18s, background 0.18s;
}

nav a:not(.brand):hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}

nav a.active {
  color: var(--white);
  background: rgba(255,255,255,0.12);
}

.points-badge {
  font-family: 'Syne', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sage-100);
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.15);
  padding: 5px 14px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  margin-left: 8px;
}

.org-badge {
  display: inline-flex;
  align-items: center;
  font-family: 'Syne', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  color: #86efac;
  background: rgba(134,239,172,0.12);
  border: 1.5px solid rgba(134,239,172,0.25);
  padding: 5px 12px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  margin-left: 4px;
  white-space: nowrap;
}

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.page {
  max-width: 860px;
  margin: 40px auto;
  padding: 0 20px 60px;
}

h1 {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 300;
  font-size: 2rem;
  color: var(--forest);
  margin-bottom: 28px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid rgba(195,222,206,0.5);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border: none;
  border-radius: 50px;
  font-family: 'Syne', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, background 0.18s;
  white-space: nowrap;
}

.btn:hover   { transform: translateY(-1px); }
.btn:active  { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--leaf);
  color: var(--white);
  box-shadow: 0 3px 12px rgba(42,122,75,0.25);
}
.btn-primary:hover {
  background: var(--leaf-hover);
  box-shadow: 0 5px 18px rgba(42,122,75,0.3);
}

.btn-secondary {
  background: var(--white);
  color: var(--body-text);
  border: 1.5px solid var(--sage-200);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: var(--sage-50);
  border-color: var(--sage-300);
}

.btn-scan {
  background: var(--forest);
  color: var(--white);
  font-size: 0.88rem;
  padding: 14px 36px;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(22,46,30,0.28);
  letter-spacing: 0.06em;
}
.btn-scan:hover {
  background: #0f2217;
  box-shadow: 0 6px 28px rgba(22,46,30,0.35);
}

.btn-danger {
  background: var(--red);
  color: var(--white);
  box-shadow: 0 3px 12px rgba(196,64,64,0.25);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ── Camera wrap ──────────────────────────────────────────────────────────── */
#camera-wrap {
  position: relative;
  width: 100%;
  background: var(--scanner-bg);
  border-radius: 12px;
  overflow: hidden;
  min-height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  border: 1px solid #1e3527;
  box-shadow: inset 0 2px 20px rgba(0,0,0,0.4);
}

#camera-wrap video,
#camera-wrap img#preview,
#camera-wrap canvas#canvas {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
}

#placeholder-text {
  color: rgba(150,196,170,0.5);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#file-input { display: none; }

/* ── AR detection overlay canvas ───────────────────────────────────────────── */
#ar-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9;
}

/* ── AR scanner overlay ────────────────────────────────────────────────────── */
#ar-scanner {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.ar-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: rgba(74,222,128,0.85);
  border-style: solid;
  border-width: 0;
}
.ar-tl { top: 16px; left: 16px; border-top-width: 2.5px; border-left-width: 2.5px; border-radius: 3px 0 0 0; }
.ar-tr { top: 16px; right: 16px; border-top-width: 2.5px; border-right-width: 2.5px; border-radius: 0 3px 0 0; }
.ar-bl { bottom: 16px; left: 16px; border-bottom-width: 2.5px; border-left-width: 2.5px; border-radius: 0 0 0 3px; }
.ar-br { bottom: 16px; right: 16px; border-bottom-width: 2.5px; border-right-width: 2.5px; border-radius: 0 0 3px 0; }

.ar-scan-line {
  position: absolute;
  left: 20px;
  right: 20px;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(74,222,128,0.95), transparent);
  box-shadow: 0 0 10px rgba(74,222,128,0.5), 0 0 20px rgba(74,222,128,0.2);
  animation: arScanLine 2.2s ease-in-out infinite;
}
@keyframes arScanLine {
  0%   { top: 12%; opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { top: 88%; opacity: 0; }
}

.ar-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
}
.ar-ch-v {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 1px;
  height: 100%;
  background: rgba(74,222,128,0.6);
}
.ar-ch-h {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 1px;
  background: rgba(74,222,128,0.6);
}

/* ── Detect status pill ────────────────────────────────────────────────────── */
#detect-status {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12,28,19,0.88);
  border: 1px solid rgba(74,222,128,0.25);
  color: rgba(74,222,128,0.95);
  padding: 5px 18px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  z-index: 20;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Detect status — scanning pulse ─────────────────────────────────────── */
#detect-status.scanning {
  color: rgba(74,222,128,0.7);
  border-color: rgba(74,222,128,0.15);
}

#detect-status.scanning::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(74,222,128,0.85);
  margin-right: 7px;
  vertical-align: middle;
  animation: arPulseDot 1s ease-in-out infinite;
}

@keyframes arPulseDot {
  0%, 100% { opacity: 1;    transform: scale(1);   }
  50%       { opacity: 0.35; transform: scale(0.7); }
}

/* ── Location section ──────────────────────────────────────────────────────── */
.location-section { margin-bottom: 22px; }

.field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.field-row label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

select {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--sage-200);
  border-radius: 50px;
  font-family: 'Syne', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--white);
  color: var(--body-text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a9882' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
  transition: border-color 0.18s;
}
select:focus {
  outline: none;
  border-color: var(--leaf);
}

/* ── GPS status ────────────────────────────────────────────────────────────── */
.gps-status {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--sage-200);
  border-top-color: var(--leaf);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin: 0 auto;
}
.spinner.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error message ─────────────────────────────────────────────────────────── */
.error-msg {
  background: #fff5f5;
  color: var(--red);
  border: 1px solid rgba(196,64,64,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 14px;
  display: none;
}
.error-msg.visible { display: block; }

/* ── Scan item cards (TikTok-style horizontal strip) ──────────────────────── */
.scan-cards {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 8px 4px 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--leaf) transparent;
}
.scan-cards::-webkit-scrollbar { height: 4px; }
.scan-cards::-webkit-scrollbar-thumb { background: var(--leaf); border-radius: 2px; }

.scan-item-card {
  flex: 0 0 200px;
  scroll-snap-align: start;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(42,122,75,0.12);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.scan-item-card:hover,
.scan-item-card.active {
  border-color: var(--accent, var(--leaf));
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(42,122,75,0.18);
}

.scan-item-thumb {
  width: 100%;
  height: 140px;
  display: block;
  object-fit: cover;
}

.scan-item-body {
  padding: 12px 14px 14px;
}

.scan-item-label {
  font-family: 'Fraunces', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--forest);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-item-material {
  font-family: 'Syne', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.scan-item-badge {
  display: inline-block;
  font-family: 'Syne', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 9px;
}
.card-badge-yes { background: var(--sage-100, #d4edda); color: var(--leaf); }
.card-badge-no  { background: #fff0f0; color: #c0392b; }

.scan-item-action {
  font-size: 0.76rem;
  color: var(--body-text, #444);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Result card ───────────────────────────────────────────────────────────── */
#result-card { display: none; }
#result-card.visible {
  display: block;
  animation: slideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.result-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 20px;
  align-items: start;
}

.result-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 2px;
}
.result-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--body-text);
}

.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-yes  { background: var(--sage-100); color: var(--leaf); }
.badge-no   { background: #fff0f0; color: var(--red); }
.badge-warn { background: #fff4e5; color: #a0620a; }

/* ── Points earned (in result card) ───────────────────────────────────────── */
.points-earned {
  margin-top: 18px;
  background: var(--sage-100);
  border: 1px solid var(--sage-200);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--leaf);
  text-align: center;
  text-transform: uppercase;
}

/* ── Points toast ──────────────────────────────────────────────────────────── */
.points-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: var(--forest);
  color: var(--white);
  padding: 11px 26px;
  border-radius: 50px;
  font-family: 'Syne', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 6px 28px rgba(22,46,30,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
  white-space: nowrap;
}
.points-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Scan log ──────────────────────────────────────────────────────────────── */
.log-entry {
  padding: 9px 0;
  border-bottom: 1px solid var(--sage-100);
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
}
.log-time {
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  padding-top: 1px;
}
.log-msg { color: var(--body-text); }

/* ── Dashboard ─────────────────────────────────────────────────────────────── */
.live-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage-300);
  display: inline-block;
  flex-shrink: 0;
}
.live-dot.connected {
  background: var(--leaf);
  animation: pulseDot 1.8s ease-in-out infinite;
}
@keyframes pulseDot {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(42,122,75,0.35); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 5px rgba(42,122,75,0); }
}

/* ── Bins grid ─────────────────────────────────────────────────────────────── */
#bins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.bin-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  border: 1px solid var(--sage-200);
  border-left: 4px solid var(--sage-300);
  transition: border-left-color 0.35s, box-shadow 0.2s;
}
.bin-card:hover   { box-shadow: var(--shadow); }
.bin-card.warning { border-left-color: var(--amber); }
.bin-card.full    { border-left-color: var(--red); }

.bin-name     { font-weight: 700; font-size: 0.95rem; margin-bottom: 3px; color: var(--forest); }
.bin-location { font-size: 0.76rem; color: var(--muted); margin-bottom: 14px; letter-spacing: 0.02em; }

.fill-bar-bg {
  background: var(--sage-100);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}
.fill-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--leaf);
  transition: width 0.5s ease, background 0.3s;
}
.fill-bar.warning { background: var(--amber); }
.fill-bar.full    { background: var(--red); }

.fill-label { font-size: 0.74rem; color: var(--muted); margin-bottom: 12px; font-weight: 600; }

.bin-meta { font-size: 0.8rem; }
.bin-meta span    { display: block; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 1px; }
.bin-meta strong  { color: var(--body-text); font-weight: 600; font-size: 0.85rem; }

/* ── Activity log ──────────────────────────────────────────────────────────── */
#activity-log {
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.84rem;
}

/* ── Time filter tabs ──────────────────────────────────────────────────────── */
.time-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
}

.tab {
  padding: 7px 20px;
  border: 1.5px solid var(--sage-200);
  background: var(--white);
  color: var(--muted);
  border-radius: 50px;
  font-family: 'Syne', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.tab:hover  { border-color: var(--sage-300); color: var(--body-text); }
.tab.active { background: var(--forest); color: var(--white); border-color: var(--forest); }

/* ── Stats row ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--white);
  border: 1px solid var(--sage-200);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-val {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--forest);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Hotspot card ──────────────────────────────────────────────────────────── */
.hotspot-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #fffbf2, #fff8e8);
  border: 1px solid #f0d9a5;
  border-left: 4px solid var(--amber);
  margin-bottom: 20px;
  padding: 18px 22px;
}
.hotspot-icon  { font-size: 1.8rem; flex-shrink: 0; }
.hotspot-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #a0620a; }
.hotspot-text  { font-size: 1rem; font-weight: 700; color: var(--forest); margin-top: 2px; }

/* ── Admin panel ───────────────────────────────────────────────────────────── */
.admin-bin-row {
  border: 1px solid var(--sage-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  background: var(--white);
}

.admin-bin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--forest);
}

.admin-bin-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.admin-bin-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Scan dot (Leaflet divIcon marker) ─────────────────────────────────────── */
.scan-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 1px 5px rgba(0,0,0,0.3);
}

@keyframes markerPulse {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0   rgba(255,255,255,0.8); }
  50%  { transform: scale(2.2); box-shadow: 0 0 0 10px rgba(255,255,255,0); }
  100% { transform: scale(1);   box-shadow: 0 0 0 0   rgba(255,255,255,0); }
}
.new-marker { animation: markerPulse 0.9s ease 3; }

.cluster-dot {
  border-radius: 50%;
  background: var(--forest);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.76rem;
  border: 2.5px solid var(--white);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* ── Leaflet live-counter control ──────────────────────────────────────────── */
.live-counter-ctrl {
  background: rgba(22,46,30,0.88);
  color: var(--white);
  padding: 10px 14px;
  border-radius: 10px;
  font-family: 'Syne', sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  min-width: 140px;
  backdrop-filter: blur(6px);
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.blink-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #ff5252;
  border-radius: 50%;
  animation: blinkDot 1.3s infinite;
  vertical-align: middle;
  margin-right: 3px;
}
@keyframes blinkDot {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.1; }
}

/* ── Map view toggle ───────────────────────────────────────────────────────── */
.map-toggle { display: flex; gap: 6px; }

.map-toggle-btn {
  padding: 5px 14px;
  border: 1.5px solid var(--sage-200);
  background: var(--white);
  color: var(--muted);
  border-radius: 16px;
  font-family: 'Syne', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
}
.map-toggle-btn:hover  { background: var(--sage-50); }
.map-toggle-btn.active { background: var(--forest); color: var(--white); border-color: var(--forest); }

/* ── Map + chart row ───────────────────────────────────────────────────────── */
.map-chart-row {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  align-items: start;
  margin-bottom: 20px;
}

.map-card, .chart-card { margin-bottom: 0; }

#map {
  height: 400px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* ── Map legend ────────────────────────────────────────────────────────────── */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
}
.map-legend span { display: flex; align-items: center; gap: 6px; }

.leg-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.5);
  flex-shrink: 0;
}

/* ── Pie chart wrapper ─────────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 310px;
  margin: 0 auto;
}

/* ── Disposal guide ────────────────────────────────────────────────────────── */
#guide-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--sage-200);
  border-left: 4px solid var(--sage-300);
  transition: box-shadow 0.2s, border-left-color 0.2s;
}
.guide-card:hover { box-shadow: var(--shadow); border-left-color: var(--leaf); }

.guide-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}
.guide-card-header:hover { background: var(--sage-50); }

.guide-icon   { font-size: 1.4rem; flex-shrink: 0; }
.guide-name   { font-size: 0.95rem; font-weight: 700; color: var(--forest); flex: 1; }
.guide-badges { display: flex; gap: 8px; flex-wrap: wrap; }

.guide-chevron {
  font-size: 0.72rem;
  color: var(--muted);
  transition: transform 0.22s;
  flex-shrink: 0;
}
.guide-card.open .guide-chevron { transform: rotate(180deg); }

.guide-card-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--sage-100);
}
.guide-card.open .guide-card-body { display: block; }

.bin-tag {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 14px 0 16px;
}

.guide-steps {
  padding-left: 20px;
  font-size: 0.88rem;
  color: var(--body-text);
  line-height: 1.85;
}
.guide-steps li { margin-bottom: 4px; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .map-chart-row { grid-template-columns: 1fr; }
  #map { height: 300px; }
}

@media (max-width: 600px) {
  nav { padding: 0 16px; gap: 2px; }
  nav a:not(.brand) { padding: 5px 10px; font-size: 0.76rem; }
  h1 { font-size: 1.6rem; }
  .page { margin: 24px auto; }
  .admin-bin-fields { grid-template-columns: 1fr; }
}

/* ── AI Chat Widget ──────────────────────────────────────────────────────── */
#ai-chat-card {
  display: none;
}

#ai-chat-card.visible {
  display: block;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.ai-chat-header-logo {
  height: 32px;
  width: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.ai-chat-header-title {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--forest);
  flex: 1;
}

.ai-chat-powered {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--sage-200) transparent;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--sage-100);
  color: var(--body-text);
  border-bottom-left-radius: 4px;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--leaf);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.chat-bubble-loading {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.chat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: chat-bounce 1.2s infinite ease-in-out;
}

.chat-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1;   }
}

.ai-chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--sage-200);
}

#chat-input {
  flex: 1;
  padding: 9px 16px;
  border: 1.5px solid var(--sage-200);
  border-radius: 50px;
  font-family: 'Syne', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--white);
  color: var(--body-text);
  outline: none;
  transition: border-color 0.18s;
}

#chat-input:focus {
  border-color: var(--leaf);
}

#chat-send {
  padding: 9px 20px;
  background: var(--leaf);
  color: var(--white);
  border: none;
  border-radius: 50px;
  font-family: 'Syne', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s;
  white-space: nowrap;
}

#chat-send:hover:not(:disabled) {
  background: var(--leaf-hover);
}

#chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
