/* ==========================================================
   Nonprofit CRM — clean, professional, high-legibility UI
   ========================================================== */
:root {
  --ink: #16232e;
  --ink-soft: #3d4d5c;
  --muted: #6b7c8c;
  --line: #e2e8ee;
  --line-strong: #cbd5e0;
  --bg: #f2f5f8;
  --card: #ffffff;
  --brand: #1f5c3d;
  --brand-dark: #17452e;
  --brand-soft: #eaf3ee;
  --accent: #b4681d;
  --danger: #a32323;
  --shadow: 0 1px 2px rgba(22, 35, 46, .06), 0 8px 24px rgba(22, 35, 46, .05);
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1220px; margin: 0 auto; padding: 0 24px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { color: var(--muted); font-weight: 400; font-size: .78rem; }
.req { color: var(--danger); }

/* ---------- Top bar ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1220px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: .95rem; }
.brand-text small { color: var(--muted); font-size: .78rem; }
.mainnav { display: flex; flex-wrap: wrap; gap: 2px; margin-right: auto; }
.mainnav a {
  padding: 8px 12px; border-radius: 8px; color: var(--ink-soft);
  font-size: .93rem; font-weight: 500;
}
.mainnav a:hover { background: #eef2f6; text-decoration: none; }
.mainnav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 12px; }
.who { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.badge {
  font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-soft);
  background: #f6f8fa;
}
.badge.admin { background: var(--brand-soft); border-color: #bcd8c7; color: var(--brand-dark); }

/* ---------- Page ---------- */
main { padding-bottom: 48px; }
.page-head { margin: 28px 0 18px; }
h1 { font-size: 1.6rem; letter-spacing: -.015em; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 14px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; }
.viewonly-note {
  display: inline-block; margin-top: 10px; padding: 6px 12px; border-radius: 999px;
  background: #fff7ec; border: 1px solid #f0d9b6; color: #8a5510; font-size: .84rem;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.card > h2:first-child { margin-top: 0; }

/* ---------- Stats ---------- */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.totals .card { margin: 0; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat.highlight { background: linear-gradient(180deg, #f2f9f4, #fff); border-color: #bcd8c7; }
.stat.highlight .stat-value { color: var(--brand); }

/* ---------- Forms ---------- */
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 20px; padding: 14px 18px 6px; }
legend { font-weight: 600; font-size: .95rem; padding: 0 8px; color: var(--ink-soft); }
.row { display: flex; flex-wrap: wrap; gap: 18px; }
.field { flex: 1 1 220px; margin-bottom: 16px; min-width: 190px; }
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .86rem; color: var(--ink-soft); }
input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
input[type="number"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  font: inherit; background: #fff; color: inherit; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 92, 61, .13);
}
select[multiple] { padding: 5px; }
textarea { resize: vertical; }
.radios { display: flex; gap: 10px; padding-top: 4px; }
.radios label {
  font-weight: 500; display: inline-flex; align-items: center; gap: 7px; margin: 0;
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 14px; background: #fff; color: var(--ink);
  cursor: pointer;
}
.radios label:hover { background: #f6f8fa; }
.checkline { font-weight: 500; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.currency { display: flex; align-items: center; gap: 6px; }
.currency span { color: var(--muted); font-weight: 600; }
.field-error { color: var(--danger); font-size: .84rem; margin: 5px 0 0; }
.error-box { background: #fdecec; border: 1px solid #e9bcbc; color: #7d1f1f; padding: 11px 14px; border-radius: 8px; }
.success-box { background: #eaf6ee; border: 1px solid #b6ddc4; color: #1c5733; padding: 11px 14px; border-radius: 8px; }
.recipients { word-break: break-all; font-size: .9rem; }

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f2f5f8; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e6bfbf; }
.btn.danger:hover { background: #fdf2f2; }
.btn.small-btn { padding: 6px 11px; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form label { margin: 0; }
.inline-form input[type="search"] { width: auto; flex: 1 1 260px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; border-radius: 8px; }
table.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
table.grid thead th {
  background: #f6f8fa; white-space: nowrap; font-size: .76rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
table.grid tbody tr:hover { background: #f8fafc; }
table.grid tbody tr:last-child td { border-bottom: none; }

/* ---------- Login ---------- */
.login-body {
  display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1000px 500px at 50% -10%, #e6efe9, var(--bg));
}
.login-card {
  width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.login-mark {
  width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; margin-bottom: 14px;
}
.login-card h1 { margin: 0; font-size: 1.25rem; }
.login-card p { margin: 4px 0 16px; }
.login-card .error-box { margin-bottom: 14px; }
.login-card .btn { margin-top: 6px; }
.login-foot { margin: 16px 0 0; }

.sitefoot { border-top: 1px solid var(--line); padding: 18px 0; background: #fff; }

@media (max-width: 720px) {
  .topbar-inner { gap: 12px; }
  .mainnav { order: 3; width: 100%; }
  .userbox { margin-left: auto; }
}
@media print {
  .topbar, .actions, .sitefoot, form.form, .viewonly-note { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; box-shadow: none; }
}
