:root {
  --green: #2e7d52;
  --green-dark: #1f5c3b;
  --green-light: #e8f3ec;
  --ink: #1c2520;
  --muted: #66756c;
  --line: #dde5e0;
  --bg: #f4f7f5;
  --card: #ffffff;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --red: #b91c1c;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
a { color: var(--green-dark); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
}
.logo { font-weight: 800; font-size: 20px; color: var(--green-dark); text-decoration: none; white-space: nowrap; }
.logo span { color: var(--green); }
.topbar .loc { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .user-chip { font-size: 14px; font-weight: 600; }

.shell { display: flex; max-width: 1100px; margin: 0 auto; gap: 24px; padding: 20px; align-items: flex-start; }

nav.side {
  width: 210px; flex-shrink: 0; position: sticky; top: 70px;
  display: flex; flex-direction: column; gap: 2px;
}
nav.side a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  text-decoration: none; color: var(--ink); font-weight: 500; font-size: 15px;
}
nav.side a:hover { background: var(--green-light); }
nav.side a.active { background: var(--green); color: #fff; }

main { flex: 1; min-width: 0; }

/* ---------- cards & common ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
}
.card h2 { font-size: 20px; margin-bottom: 4px; }
.card h3 { font-size: 16px; }
.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--muted); font-size: 14px; }
.meta { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--green-light); color: var(--green-dark);
}
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.gray { background: #eef1ef; color: var(--muted); }

/* ---------- admin metrics ---------- */
.spark-chart {
  display: flex; align-items: flex-end; gap: 2px; height: 80px;
}
.spark-bar {
  flex: 1; min-width: 3px; background: var(--green); border-radius: 2px 2px 0 0;
  opacity: 0.85;
}
.spark-bar:hover { opacity: 1; }
.admin-metrics-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-metrics-table th, .admin-metrics-table td {
  text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.admin-metrics-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.btn {
  background: var(--green); color: #fff; border: none;
  padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 14px;
}
.btn:hover { background: var(--green-dark); }
.btn.secondary { background: var(--card); color: var(--green-dark); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--green-light); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }

.linklike { background: none; border: none; color: var(--muted); font-size: 13px; padding: 0; }
.linklike:hover { color: var(--green-dark); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
}
textarea { resize: vertical; min-height: 70px; }
label.field { display: block; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
label.field > * { margin-top: 4px; font-weight: 400; }

.combo { position: relative; }
.combo input:disabled { background: var(--bg); color: var(--muted); }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.1);
}
.combo-item { padding: 8px 12px; cursor: pointer; font-size: 14px; }
.combo-item:hover, .combo-item.active { background: var(--green-light); }
.combo-item.empty { color: var(--muted); cursor: default; }

.error-box { background: #fee2e2; color: var(--red); padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 14px; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 5px 14px; font-size: 13px; font-weight: 500;
}
.chip.active { background: var(--green); color: #fff; border-color: var(--green); }

/* ---------- auth ---------- */
.auth-wrap { max-width: 440px; margin: 40px auto; padding: 0 20px; }
.auth-hero { text-align: center; margin-bottom: 24px; }
.auth-hero .mark { font-size: 44px; }
.auth-hero h1 { font-size: 28px; color: var(--green-dark); }
.auth-hero p { color: var(--muted); }
.auth-tabs { display: flex; gap: 0; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.auth-tabs button { flex: 1; padding: 10px; border: none; background: var(--card); font-weight: 600; }
.auth-tabs button.active { background: var(--green); color: #fff; }
.demo-hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 14px; }

/* ---------- feed ---------- */
.composer textarea { margin-bottom: 10px; }
.post-body { margin: 6px 0 10px; white-space: pre-wrap; }
.comments { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.comment { font-size: 14px; margin-bottom: 8px; }
.comment .who { font-weight: 600; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { flex: 1; }

/* ---------- grids ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.price { font-size: 18px; font-weight: 700; color: var(--green-dark); }

/* ---------- politicians ---------- */
.pol-card { display: flex; gap: 14px; }
.pol-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.pol-updates { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.level-head { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.level-head:first-child { margin-top: 0; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(20,30,24,.5); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 12px; font-size: 19px; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  nav.side { width: 100%; position: static; flex-direction: row; overflow-x: auto; }
  nav.side a { white-space: nowrap; }
  .topbar .loc { display: none; }
}

/* ---------- topbar search + bell ---------- */
.topsearch { flex: 0 1 260px; }
.topsearch input { width: 100%; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; font: inherit; font-size: 14px; background: #f4f6f4; }
.bell { position: relative; text-decoration: none; font-size: 18px; padding: 4px; }
.dot { position: absolute; top: -2px; right: -6px; background: #d33; color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700; min-width: 15px; height: 15px; line-height: 15px; text-align: center; padding: 0 3px; }
nav.side a { position: relative; }
nav.side .dot { position: static; display: inline-block; margin-left: 6px; }

/* ---------- notifications & message list ---------- */
.notif { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.notif.unread { border-left: 3px solid var(--green); background: #f2f8f3; }
.notif-icon { font-size: 20px; }

/* ---------- message thread ---------- */
.thread { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 75%; align-self: flex-start; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg .bubble { display: inline-block; padding: 8px 13px; border-radius: 14px; background: #eef1ef; text-align: left; white-space: pre-wrap; word-break: break-word; }
.msg.mine .bubble { background: var(--green); color: #fff; }

/* ---------- post images ---------- */
.post-img { max-width: 100%; max-height: 420px; border-radius: 10px; margin: 8px 0; display: block; }
.img-preview img { max-width: 180px; max-height: 140px; border-radius: 8px; margin-top: 6px; }

/* ---------- verified badge ---------- */
.verified { color: var(--green); font-weight: 700; margin-left: 4px; font-size: 13px; }

/* ---------- inline notice cards (verify nudge, invite banner, nearby explainer) ---------- */
.notice-card { font-size: 14px; }
.notice-card.amber { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.notice-card.green { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }
.notice-card.blue { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }

/* ---------- groups ---------- */
.group-link { cursor: pointer; }
.group-link:hover { color: var(--green); text-decoration: underline; }

/* ---------- message thread controls ---------- */
#load-earlier { align-self: center; width: auto; }

/* ---------- polls ---------- */
.poll { margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.poll-row { position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; cursor: pointer; text-align: left; }
.poll-row:hover { border-color: var(--green); }
.poll-row.voted { border-color: var(--green); font-weight: 600; }
.poll-fill { position: absolute; inset: 0 auto 0 0; background: #e2efe4; z-index: 0; }
.poll-label, .poll-pct { position: relative; z-index: 1; }
.poll-opt { display: block; width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
