:root {
  /* SATSA brand: green and gold from transplantsports.org.za */
  --accent: #007a4d; --accent-dark: #005c3a; --accent-soft: #e3f2ea;
  --gold: #ffb612; --gold-soft: #fff3d1;
  --bg: #f4f6f5; --panel: #ffffff; --border: #e3e7e5; --text: #2b2b2b; --muted: #666666;
  --ok: #007a4d; --danger: #c62828; --warn: #d97706; --radius: 8px;
  --font-head: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font-body); background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; font-family: var(--font-head); }
h1 { font-size: 22px; color: #1f3d2e; } h2 { font-size: 16px; } h3 { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #ffffff; color: var(--text); padding: 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 8px 16px; margin-bottom: 6px; border-bottom: 3px solid var(--gold); font-family: var(--font-head); font-weight: 700; font-size: 14px; color: var(--accent); line-height: 1.2; }
.brand .logo { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-size: 13px; color: #fff; flex: none; }
.brand img { height: 42px; width: auto; max-width: 120px; display: block; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; color: #555; font-weight: 600; font-family: var(--font-head); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; border-left: 3px solid transparent; }
.nav a:hover { background: var(--accent-soft); color: var(--accent); }
.nav a.active { background: var(--accent); color: #fff; border-left-color: var(--gold); }
.nav .sep { margin: 12px 12px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #9aa39e; font-family: var(--font-head); }
.sidebar .user { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.sidebar .user b { display: block; color: var(--text); }
.sidebar .user button { margin-top: 8px; display: block; }
.main { padding: 22px 26px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.stat { padding: 16px; }
.stat .n { font-size: 30px; font-weight: 700; color: var(--accent); font-family: var(--font-head); }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.bars { display: grid; gap: 6px; }
.bars .row { display: grid; grid-template-columns: 140px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.bars .bar { height: 10px; background: var(--accent-soft); border-radius: 5px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #2a9d6a); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #fafafa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-family: var(--font-head); font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.success { background: var(--gold); border-color: var(--gold); color: #1f3d2e; font-family: var(--font-head); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 6px 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 6px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.field input[readonly] { background: #f9fafb; color: var(--muted); }
.field .err { color: var(--danger); font-size: 12px; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text); font-size: 13px; white-space: nowrap; }
.block { margin-bottom: 18px; }
.block > h3 { padding-bottom: 6px; border-bottom: 2px solid var(--gold); margin-bottom: 12px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; min-width: 260px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* Tables */
.table-wrap { overflow: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
th { background: #f1f6f3; font-weight: 600; color: var(--muted); position: sticky; top: 0; cursor: pointer; user-select: none; }
th.sorted { color: var(--accent); }
tbody tr:hover { background: #f6fbf8; }
tbody tr.clickable { cursor: pointer; }
td.actions { text-align: right; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.s-active { background: var(--accent-soft); color: var(--accent-dark); }
.badge.s-new { background: var(--gold-soft); color: #7a5200; }
.badge.s-deceased { background: #f3f4f6; color: #374151; }
.badge.s-resigned { background: #fef3c7; color: #92400e; }
.badge.s-blank { background: #f3f4f6; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #005c3a 0%, #007a4d 55%, #0b8f5c 100%); }
.login .card { width: 380px; background: #fff; border-radius: 12px; padding: 32px 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); display: grid; gap: 14px; border-top: 5px solid var(--gold); }
.login .card h1 { text-align: center; font-size: 18px; }
.login .card .logo { margin: 0 auto 6px; width: 48px; height: 48px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-family: var(--font-head); }
.login .card img { display: block; margin: 0 auto 4px; height: 64px; width: auto; }
.login .tag { text-align: center; color: var(--muted); font-size: 12px; margin-top: -6px; }

/* Modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 25px 60px rgba(0,0,0,.35); }
.modal .head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 20px; }
.modal .foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 22px; right: 22px; background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-weight: 500; }
.toast.ok { background: var(--accent); } .toast.err { background: var(--danger); }
.saved-badge { color: var(--accent); font-weight: 600; font-size: 13px; }
.muted { color: var(--muted); }
.mt { margin-top: 14px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .user { margin: 0; border: 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; } .nav .sep { display: none; }
  .main { padding: 14px; }
}
