/* Faithful Steward — phone-first. One file, no build step. */
:root {
  --ink: #1c2420;
  --muted: #68716c;
  --line: #e3e0d8;
  --green-950: #0e2a1f;
  --green-900: #123527;
  --green-700: #1e5b45;
  --green-600: #27735a;
  --green-050: #ecf4ef;
  --gold: #c9a227;
  --gold-soft: #f4ead0;
  --danger: #b03434;
  --danger-soft: #fbeaea;
  --bg: #f7f5f0;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 35, 27, 0.05), 0 4px 16px rgba(18, 35, 27, 0.07);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Segoe UI Variable Text", "Segoe UI", -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 80% -200px, #efe9db 0%, transparent 60%),
    var(--bg);
  font-size: 16px;
  line-height: 1.5;
}
main { padding: 20px 24px 48px; max-width: 1240px; margin: 0 auto; }
h1 {
  font-size: 1.55rem; margin: 0.5em 0 0.7em; letter-spacing: -0.015em;
  font-weight: 700; color: var(--green-950);
}
h2 { font-size: 1rem; margin: 0.2em 0 0.6em; font-weight: 650; color: var(--green-900); }
a { color: var(--green-700); text-underline-offset: 2px; }
code { background: #efece4; border-radius: 4px; padding: 1px 5px; font-size: 0.9em; }
.muted { color: var(--muted); font-weight: normal; font-size: 0.9em; }
.small-caps {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem;
  font-weight: 700; margin: 12px 0 6px;
}

/* ---- top bar: brand + sign-out on the first row, nav as a scrollable
       strip beneath on narrow screens; single row on wide screens ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--green-950), var(--green-700));
  color: #fff; padding: 10px 16px 8px;
  box-shadow: 0 2px 12px rgba(14, 42, 31, 0.35);
}
.brand {
  color: #fff; font-weight: 750; text-decoration: none; font-size: 1.08rem;
  letter-spacing: -0.01em; white-space: nowrap; order: 1; flex: 1;
}
.brand-mark { color: var(--gold); }
.brand-mark.big { font-size: 2rem; }
.logout-form { margin: 0; order: 2; }
.topbar nav {
  display: flex; gap: 2px 4px; order: 3; flex-basis: 100%;
  flex-wrap: wrap; padding-bottom: 2px;
}
.topbar nav a {
  color: #dcebe2; text-decoration: none; padding: 5px 11px; border-radius: 999px;
  font-size: 0.92rem; white-space: nowrap; transition: background 0.15s ease;
}
.topbar nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.topbar .link-button { color: #bcd4c6; font-size: 0.9rem; text-decoration: none; }
.topbar .link-button:hover { color: #fff; text-decoration: underline; }
@media (min-width: 900px) {
  .topbar { padding: 12px 20px; gap: 16px 20px; }
  .brand { flex: 0 0 auto; }
  .topbar nav { order: 2; flex: 1; flex-basis: auto; justify-content: flex-start; }
  .logout-form { order: 3; }
}

/* ---- members table: tidy, no sprawling empty space, no cell overlap ---- */
.members-table { table-layout: auto; }
.members-table th, .members-table td { white-space: nowrap; vertical-align: middle; }
.members-table .name-col { white-space: normal; }
.members-table .name-col a { font-weight: 700; color: var(--green-950); text-decoration: none; }
.members-table .name-col a:hover { color: var(--green-700); text-decoration: underline; }
.members-table .tg-col { max-width: 200px; white-space: normal; overflow-wrap: anywhere; font-size: 0.9em; }
.members-table .num { font-variant-numeric: tabular-nums; text-align: right; }
.members-table .zero { color: #c9c4b6; }
.members-table thead th { font-size: 0.7rem; }
/* actions live in an inner flex box so the <td> stays a normal table cell
   (a display:flex td collapses and overlaps its neighbour) */
.members-table .actions-col { text-align: right; padding-left: 18px; }
.members-table .actions-inner { display: inline-flex; gap: 14px; align-items: center; white-space: nowrap; }
.members-table .actions-inner form { margin: 0; }

/* ---- members list toolbar: Add member + live name search ---- */
.members-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.members-toolbar .member-search { flex: 1; min-width: 180px; max-width: 340px; }

/* the "add new member" reveal input under a member picker */
.new-member-input { margin-top: -2px; }

/* ---- member form: two columns of fields that fill the width ---- */
.member-layout { display: grid; gap: 18px; grid-template-columns: 1fr; align-items: start; }
.member-form .form-grid { display: grid; grid-template-columns: 1fr; gap: 10px 18px; }
.member-form .field { display: flex; flex-direction: column; gap: 4px; }
.member-form label { font-weight: 600; font-size: 0.9em; color: var(--green-950); }
.member-form .primary { margin-top: 14px; }
@media (min-width: 640px) {
  .member-form .form-grid { grid-template-columns: 1fr 1fr; }
  .member-form .field-wide { grid-column: 1 / -1; }
}
@media (min-width: 980px) {
  .member-layout { grid-template-columns: 1fr 300px; }
}

/* ---- login ---- */
.login-page {
  display: flex; min-height: 100vh; align-items: center; justify-content: center;
  background:
    radial-gradient(800px 500px at 20% 0%, rgba(31, 92, 69, 0.12), transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(201, 162, 39, 0.10), transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--card); padding: 40px 36px; border-radius: 18px;
  box-shadow: var(--shadow), 0 24px 60px rgba(14, 42, 31, 0.12);
  width: min(380px, 92vw); text-align: center; border: 1px solid var(--line);
}
.login-card h1 { margin: 6px 0 0; color: var(--green-900); }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; text-align: left; }

/* ---- forms ---- */
label { font-weight: 600; font-size: 0.9em; margin-top: 8px; color: var(--green-950); }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  width: 100%; background: #fff; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(39, 115, 90, 0.18);
}
.stack { display: flex; flex-direction: column; gap: 8px; max-width: 500px; }
.stack details { border: 1px dashed var(--line); border-radius: 9px; padding: 10px 14px; background: #fbfaf7; }
.stack summary { cursor: pointer; color: var(--muted); font-size: 0.92em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

button.primary, .button {
  display: inline-block; background: linear-gradient(135deg, var(--green-700), var(--green-600));
  color: #fff; border: 0; padding: 12px 20px; border-radius: 9px; font: inherit; font-weight: 650;
  cursor: pointer; text-decoration: none; margin-top: 8px;
  box-shadow: 0 2px 6px rgba(30, 91, 69, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
button.primary:hover, .button:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30, 91, 69, 0.4); }
button.primary:active, .button:active { transform: translateY(0); }
.button.secondary {
  background: #fff; color: var(--green-700); border: 1.5px solid var(--green-700); box-shadow: none;
}
.button.secondary:hover { background: var(--green-050); }
button.small {
  font: inherit; font-size: 0.85em; padding: 7px 12px; border-radius: 7px; border: 1px solid var(--green-700);
  background: #fff; color: var(--green-700); cursor: pointer; font-weight: 600;
}
button.small:hover { background: var(--green-050); }
.link-button {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--green-700); text-decoration: underline; text-underline-offset: 2px;
}
.link-button.danger { color: var(--danger); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }

/* ---- tables ---- */
table {
  border-collapse: separate; border-spacing: 0; width: 100%;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #efede7; }
tbody tr:last-child td { border-bottom: 0; }
thead th {
  background: #f2efe8; font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: #5a615c; font-weight: 700;
}
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: #fafcf9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { max-width: 380px; }
td.reason-cell { color: var(--muted); font-style: italic; }
table.mini { box-shadow: none; border: 0; border-radius: 0; background: transparent; }
table.mini td { padding: 3px 6px; border: 0; font-size: 0.9em; }
tr.inactive-row td { color: var(--muted); }
tfoot .grand td {
  font-weight: 750; border-top: 2px solid var(--green-900); background: #f2efe8;
  font-variant-numeric: tabular-nums;
}
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
.row-actions { display: flex; gap: 12px; align-items: center; }
.row-actions form { margin: 0; }

/* ---- cards / layout ---- */
.cards { display: grid; gap: 14px; grid-template-columns: 1fr; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.stat-card { border-top: 3px solid var(--green-600); }
.stat-card.prev-month { border-top-color: #b9c6bf; }
.big-number {
  font-size: 2.1rem; font-weight: 750; margin: 2px 0; color: var(--green-950);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.split { display: grid; gap: 18px; grid-template-columns: 1fr; }
.report-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.report-list { line-height: 2.1; padding-left: 1.2em; }

/* ---- flash + tags + chips ---- */
.flash { padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); }
.flash-ok { background: #e8f4ec; color: #1d5c36; border: 1px solid #bfdecb; }
.flash-error { background: var(--danger-soft); color: #8c2020; border: 1px solid #eec3c3; }
.tag {
  display: inline-block; background: #edeae2; color: #5a615c; border-radius: 999px;
  font-size: 0.7em; padding: 2px 8px; vertical-align: middle; font-weight: 600;
}
.tag.gold { background: var(--gold-soft); color: #7c6215; }
.tag.ok { background: #e8f4ec; color: #1d5c36; }
.tag.bad { background: var(--danger-soft); color: #8c2020; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip {
  display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 0.85em;
  background: #efece4; color: #4c534e; border: 1px solid #e0dcd0; font-weight: 550;
}
.chip-upper {
  background: var(--danger-soft); color: var(--danger); border-color: #edc9c9; font-weight: 700;
}
.chip-soldier {
  background: #fdf1e0; color: #9a6210; border-color: #eed7b0; font-weight: 700;
}
.chip-upper.has-reason, .chip-soldier.has-reason {
  background: var(--gold-soft); color: #7c6215; border-color: #e6d5a5;
}
.all-given { color: #1d5c36; font-weight: 600; }

/* ---- no-alms panel ---- */
.no-alms-panel { border-left: 4px solid var(--gold); margin-bottom: 18px; }
.no-alms-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.no-alms-list li { display: flex; flex-direction: column; gap: 5px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.no-alms-list li:last-child { border-bottom: 0; }
.no-alms-list .who { font-weight: 600; }
.no-alms-list li.tier-upper .who { color: var(--danger); }
.no-alms-list li.tier-upper .who::after {
  content: "upper leadership"; margin-left: 8px; font-size: 0.68em; font-weight: 700;
  color: var(--danger); text-transform: uppercase; letter-spacing: 0.06em;
}
.no-alms-list li.tier-leader .who { color: var(--danger); }
.no-alms-list li.tier-leader .who::after {
  content: "leadership"; margin-left: 8px; font-size: 0.68em; font-weight: 700;
  color: var(--danger); text-transform: uppercase; letter-spacing: 0.06em;
}
.form-card { width: min(460px, 94vw); }

/* ---- worksheet ---- */
.worksheet-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.count-table td { padding: 4px 6px; }
.count-table input { width: 5.5em; text-align: right; }
.section-total { font-weight: 700; text-align: right; margin: 8px 2px 0; color: var(--green-950); }
.total-card { border-top: 3px solid var(--gold); }
.inline-create { margin-bottom: 18px; }
.field-row-3 { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: end; }
.field-row-3 > div { display: flex; flex-direction: column; }
.field-row-3 label { min-height: 1.2em; }
.tag.status-draft { background: #edeae2; color: #5a615c; }
.tag.status-counted { background: #fdf1e0; color: #9a6210; }
.tag.status-deposited { background: #e2ecf7; color: #274f79; }
.tag.status-reconciled { background: #e8f4ec; color: #1d5c36; }
.sign-blocks { display: grid; gap: 16px; grid-template-columns: 1fr; }
.sig-pad { border: 1.5px dashed var(--line); border-radius: 8px; background: #fbfaf7; touch-action: none; width: 100%; max-width: 360px; }
.sig-image { max-width: 240px; max-height: 90px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.lifecycle-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 8px; }
.lifecycle-actions form { margin: 0; }

/* ---- reports ---- */
.report-params { margin: 10px 0 16px; flex-wrap: wrap; gap: 12px; }
.report-params label { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.report-params input, .report-params select { width: auto; }
.report-section { margin-bottom: 22px; }
.total-row td { font-weight: 700; background: #f2efe8; }
.narrative { border-left: 4px solid var(--gold); }

/* ---- expenses ---- */
.overdue-panel { border-left: 4px solid var(--danger); margin-bottom: 16px; }
.overdue-cell strong, .overdue-row td:first-child { color: var(--danger); }
.overdue-row td { background: var(--danger-soft); }

/* ---- fundraiser people chips ---- */
.people-panel { margin-top: 16px; }
.chip-person {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-050); color: var(--green-900); border-color: #cfe2d7;
  font-weight: 600; padding-right: 6px;
}
.chip-x-form { display: inline; margin: 0; }
.chip-x {
  border: 0; background: #d5e5db; color: var(--green-900); border-radius: 999px;
  width: 18px; height: 18px; line-height: 1; font-size: 13px; font-weight: 700;
  cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.chip-x:hover { background: var(--danger); color: #fff; }
.add-person { margin-top: 10px; gap: 8px; }
.add-person select { max-width: 260px; }
.editing-card { outline: 2px solid var(--green-600); }

/* ---- fundraisers ---- */
.fundraiser-card { margin-bottom: 14px; }
.fundraiser-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.raised-line strong { font-size: 1.25em; color: var(--green-950); }
.progress { height: 10px; border-radius: 999px; background: #e8e4da; overflow: hidden; margin: 6px 0; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green-600), var(--gold)); }
select[multiple] { min-height: 6em; }

@media (min-width: 900px) {
  .worksheet-grid { grid-template-columns: 1fr 1fr; }
  .field-row-3 { grid-template-columns: 1fr 2fr 1fr; }
  .sign-blocks { grid-template-columns: 1fr 1fr; }
}
.reason-form { display: flex; gap: 6px; }
.reason-form input { flex: 1; }
.reason-form button { flex-shrink: 0; margin: 0; }

/* ---- member stat panel ---- */
.stat-panel { border-top: 3px solid var(--gold); align-self: start; }
.stat-list { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.stat-list div {
  display: flex; justify-content: space-between; padding: 9px 2px;
  border-bottom: 1px dashed var(--line);
}
.stat-list div:last-child { border-bottom: 0; }
.stat-list dt { color: var(--muted); font-size: 0.92em; }
.stat-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--green-950); }
.stat-list .stat-total { border-top: 2px solid var(--green-900); border-bottom: 0; margin-top: 4px; }
.stat-list .stat-total dt { color: var(--green-950); font-weight: 700; }

@media (min-width: 720px) {
  main { padding: 26px 24px 60px; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .split { grid-template-columns: 460px 1fr; align-items: start; }
  h1 { font-size: 1.8rem; }
}
