/* ====================================================================
   StewardshipHQ — application stylesheet
   Palette:
     Primary #003278 (nav, headers, brand anchors) · hover #0B3A6E · active #001F4D
     Secondary Gold #D5B679 · hover #C9A35A · active #B88F44
     Blue 500 #1F6FB2 (links, info, charts) · hover #155A92 · active #0F4672
     Sand 100 #F4E9D1 · Slate 900 #1F2937 · Slate 600 #64748B
     Border #D9E1EA · Surface #F8FAFC
     Success #2E8B57 · Warning #D97706 · Error #C23B22 · Info #2A77C7
   Balance: ~70% neutral surfaces/text, 20% brand blue, 10% gold + status.
   ==================================================================== */
:root {
  --primary:        #003278;
  --primary-hover:  #0B3A6E;
  --primary-active: #001F4D;
  --gold:           #D5B679;
  --gold-hover:     #C9A35A;
  --gold-active:    #B88F44;
  --link:           #1F6FB2;
  --link-hover:     #155A92;
  --link-active:    #0F4672;
  --navy:           #003278;   /* brand anchor (headings, sidebar) */
  --slate:          #1F6FB2;   /* charts, supportive interface color */
  --ink:            #1F2937;   /* Slate 900 — primary text */
  --ink-soft:       #64748B;   /* Slate 600 — secondary text */
  --line:           #D9E1EA;   /* borders, dividers */
  --sky:            #F8FAFC;   /* surface */
  --sand:           #F4E9D1;   /* Sand 100 — pills, soft highlights */
  --success:        #2E8B57;
  --warning:        #D97706;
  --error:          #C23B22;
  --info:           #2A77C7;
  /* aliases kept for existing rules */
  --navy-deep:   #003278;
  --navy-soft:   #0B3A6E;
  --gold-soft:   #F4E9D1;
  --cream:       #F8FAFC;
  --cloud:       #F8FAFC;
  --paper:       #ffffff;
  --green:       #2E8B57;
  --red:         #C23B22;
  --radius:      10px;
  --font-ui:     'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-brand:  'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  background: var(--cream);
}
a { color: var(--link); }
a:hover { color: var(--link-hover); }
a:active { color: var(--link-active); }

/* -- Top bar ---------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--paper);
  color: var(--ink);
  padding: 0 22px;
  height: 60px;
  border-bottom: 3px solid var(--gold);
}
.wordmark {
  font-family: var(--font-brand);
  font-weight: 650;
  font-size: 24px;
  color: #fff;
  text-decoration: none;
  letter-spacing: .01em;
}
.wordmark .plus { color: var(--gold); }
.brand { display: inline-flex; align-items: center; }
.brand img { height: 36px; width: auto; display: block; }
.church-logo { height: 36px; width: auto; border-radius: 5px; background: #fff; padding: 2px; }
.topbar-church {
  font-size: 13px; color: rgba(255,255,255,.65);
  border-left: 1px solid rgba(255,255,255,.2);
  padding-left: 18px;
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; color: var(--ink); font-weight: 500; }
.role-pill {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  background: var(--sand); color: var(--navy);
  border: 1px solid var(--gold);
  padding: 2px 9px; border-radius: 99px;
}

/* Second header row: church name */
.churchbar {
  background: var(--primary); color: #fff;
  font-family: var(--font-brand); font-weight: 650; font-size: 18px;
  padding: 8px 22px; letter-spacing: .01em;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

/* Hamburger (mobile only; hidden on desktop) */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 38px; height: 34px; padding: 7px; margin-right: 4px;
  background: transparent; border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; background: var(--navy); border-radius: 2px; transition: .2s; }

/* Church logo at the top of the sidebar (above Ministry) */
.sidebar-logo {
  background: #fff; border-radius: 9px; padding: 12px;
  margin: 2px 6px 14px; text-align: center;
}
.sidebar-logo img { max-width: 100%; max-height: 90px; width: auto; height: auto; display: inline-block; }

/* -- Layout ------------------------------------------------------------ */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 218px; flex-shrink: 0;
  background: var(--navy);
  padding: 18px 12px;
}
.nav-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.4);
  margin: 18px 10px 6px;
}
.nav-label:first-child { margin-top: 4px; }
.nav-link {
  display: block;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 7px;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--primary-hover); color: #fff; }
.nav-link.active {
  background: var(--primary-hover); color: #fff;
  box-shadow: inset 3px 0 0 var(--gold);
}
.content { flex: 1; padding: 28px 34px 60px; max-width: 1180px; }

/* -- Page headings ------------------------------------------------------ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 {
  font-family: var(--font-brand);
  font-weight: 650; font-size: 27px;
  margin: 0 0 6px;
  color: var(--navy-deep);
}
.page-head h1::after {
  content: ""; display: block; width: 46px; height: 3px;
  background: var(--gold); margin-top: 8px; border-radius: 2px;
}
.page-sub { color: var(--ink-soft); font-size: 14px; margin: 0; }
h2 { font-size: 17px; font-weight: 600; color: var(--navy-deep); margin: 0 0 12px; }

/* -- Cards & stats ------------------------------------------------------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.stat .stat-value { font-size: 26px; font-weight: 700; color: var(--navy-deep); }
.stat .stat-label { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* -- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--paper); }
.card table { background: transparent; }
th {
  text-align: left; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft);
  padding: 9px 12px; border-bottom: 2px solid var(--line);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f6f2e8; }
td.num, th.num { text-align: right; }

/* -- Forms ------------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span-2 { grid-column: span 2; }
label { font-size: 13px; font-weight: 600; color: var(--navy-deep); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=tel], select, textarea {
  font: inherit; color: var(--ink);
  border: 1px solid #cfc8b8; border-radius: 7px;
  padding: 8px 10px; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold);
}
textarea { min-height: 90px; resize: vertical; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; }

/* -- Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-block; font: inherit; font-size: 14px; font-weight: 600;
  border: 1px solid transparent; border-radius: 7px;
  padding: 8px 16px; cursor: pointer; text-decoration: none;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { background: var(--primary-active); }
.btn-gold { background: var(--gold); color: #1F2937; }
.btn-gold:hover { background: var(--gold-hover); }
.btn-gold:active { background: var(--gold-active); }
.btn-outline { background: transparent; color: var(--link); border-color: var(--line); }
.btn-outline:hover { background: var(--sky); }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #A8321D; }
.btn-danger:active { background: #8F2817; }

.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--sky); color: var(--navy); }
.btn-sm { padding: 4px 11px; font-size: 12.5px; }

/* -- Badges & flashes ----------------------------------------------------------- */
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 2px 9px; border-radius: 99px;
  background: #eef0f5; color: var(--navy-soft);
}
.badge-member  { background: #e3efe7; color: var(--green); }
.badge-visitor { background: #FDF1E0; color: var(--warning); }
.badge-regular { background: #e7edf8; color: var(--navy-soft); }
.badge-inactive, .badge-removed, .badge-deceased { background: #f0eeea; color: var(--ink-soft); }
.flash { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash-success { background: #E7F5EC; border-color: #C8E7D0; color: var(--success); }
.flash-error   { background: #F9ECEA; border-color: #EBCAC2; color: var(--error); }
.flash-warning { background: #FDF1E0; border-color: #EFD3A8; color: var(--warning); }
.flash-info    { background: #EAF2FB; border-color: #BFD8F0; color: var(--info); }

/* -- Utility -------------------------------------------------------------------- */
.muted { color: var(--ink-soft); }
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-bar input[type=text] { min-width: 230px; }
.empty {
  text-align: center; color: var(--ink-soft);
  padding: 36px 20px; font-size: 14px;
}
.checkin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 16px; }
.checkin-grid label { font-weight: 400; display: flex; gap: 8px; align-items: center; font-size: 14px; }

/* -- Login page -------------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy-deep) 0%, var(--navy) 60%, var(--navy-soft) 100%);
  padding: 20px;
}
.login-card {
  background: var(--paper); border-radius: 14px;
  border-top: 4px solid var(--gold);
  width: 100%; max-width: 400px;
  padding: 36px 34px;
}
.login-card .wordmark { color: var(--navy-deep); font-size: 34px; display: block; text-align: center; margin-bottom: 4px; }
.login-tagline { text-align: center; color: var(--ink-soft); font-size: 13.5px; margin: 0 0 24px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* -- Responsive ----------------------------------------------------------------------- */
@media (max-width: 860px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .nav-toggle { display: flex; }
  .brand img { height: 28px; }
  .user-name { display: none; }
  .churchbar { font-size: 16px; padding: 7px 16px; text-align: center; }
  .layout { flex-direction: column; }

  /* Sidebar becomes a slide-down menu, hidden until the hamburger is tapped */
  .sidebar {
    width: 100%; padding: 8px 10px 12px;
    display: none;
  }
  body.nav-open .sidebar { display: block; }
  .sidebar-logo { max-width: 220px; margin: 6px auto 12px; }
  .nav-label { margin: 12px 6px 4px; }
  .nav-link { padding: 11px 12px; font-size: 15px; }  /* bigger touch targets */

  .content { padding: 18px 16px 50px; }
  .field.span-2 { grid-column: span 1; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .table-wrap { overflow-x: auto; }
}

@media print {
  .topbar, .churchbar, .sidebar, .nav-toggle, .btn, .search-bar, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: none !important; box-shadow: none !important; padding: 0 !important; }
  a { color: #000 !important; text-decoration: none; }
}
@page { margin: 14mm; }

/* ====================================================================
   v1.2 additions
   ==================================================================== */

/* Login brand image */
.login-brand { display: block; width: 100%; max-width: 300px; margin: 0 auto 8px; height: auto; }
.login-card { background: var(--navy-deep); border-top-color: var(--gold); }
.login-card .login-tagline { color: rgba(255,255,255,.65); }
.login-card label { color: rgba(255,255,255,.85); }
.login-card .flash-error { background: rgba(179,56,47,.15); border-color: rgba(236,200,196,.4); color: #f3b9b3; }

/* Member avatars */
.avatar, .avatar-lg {
  border-radius: 50%; object-fit: cover; background: var(--navy-soft);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0;
}
.avatar    { width: 34px; height: 34px; font-size: 13px; }
.avatar-lg { width: 84px; height: 84px; font-size: 28px; border: 3px solid var(--gold); }
td .avatar { vertical-align: middle; margin-right: 9px; }
.profile-head { display: flex; gap: 18px; align-items: center; }

/* Import preview */
.import-status-new     { color: var(--green); font-weight: 600; }
.import-status-update  { color: #8a6d10; font-weight: 600; }
.import-status-skip    { color: var(--ink-soft); }
.import-status-flag    { color: var(--red); font-weight: 600; }

/* ---- Print Center output documents ---- */
.doc-page { background: #fff; color: #111; }

/* Directory */
.dir-entry { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #ddd; break-inside: avoid; }
.dir-photo { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; }
.dir-name { font-weight: 700; }
.dir-meta { font-size: 12.5px; color: #444; }
.dir-compact { columns: 2; column-gap: 28px; }
.dir-compact .dir-entry { display: block; }

/* Avery label sheets (printed at 100% scale, Letter paper) */
.labels { display: grid; box-sizing: border-box; }
.labels * { box-sizing: border-box; }
.label { overflow: hidden; padding: 6px 10px; font-size: 12px; line-height: 1.25;
         display: flex; flex-direction: column; justify-content: center; }
/* 5160: 3 cols x 10 rows, 2.625in x 1in */
.labels-5160 { grid-template-columns: repeat(3, 2.625in); grid-auto-rows: 1in;
               column-gap: 0.125in; padding: 0.5in 0.1875in; }
/* 5161: 2 cols x 10 rows, 4in x 1in */
.labels-5161 { grid-template-columns: repeat(2, 4in); grid-auto-rows: 1in;
               column-gap: 0.15625in; padding: 0.5in 0.15625in; }
/* 5163: 2 cols x 5 rows, 4in x 2in */
.labels-5163 { grid-template-columns: repeat(2, 4in); grid-auto-rows: 2in;
               column-gap: 0.15625in; padding: 0.5in 0.15625in; }

/* Avery 5395 name tags: 2 cols x 4 rows, 3.375in x 2.33in */
.tags { display: grid; grid-template-columns: repeat(2, 3.375in); grid-auto-rows: 2.33in;
        column-gap: 0.75in; justify-content: center; padding: 0.59in 0; }
.tag { border: 1px dashed #ccc; border-radius: 8px; display: flex; flex-direction: column;
       align-items: center; justify-content: center; text-align: center; padding: 10px; overflow: hidden; }
.tag-hello { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #8a6d10; }
.tag-name  { font-family: var(--font-brand); font-size: 24px; font-weight: 650; color: var(--navy); }
.tag-sub   { font-size: 13px; color: #555; }
.tag .qr   { margin-top: 6px; }

/* QR sheets */
.qr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
.qr-cell { text-align: center; break-inside: avoid; font-size: 12.5px; }
.qr-cell .qr { display: inline-block; padding: 6px; background: #fff; }

/* Letters */
.letter { page-break-after: always; padding: 0.4in 0; max-width: 6.5in; font-size: 14px; line-height: 1.55; }
.letter:last-child { page-break-after: auto; }

@media print {
  .no-print, .print-config { display: none !important; }
  .doc-page { margin: 0; }
  .labels, .tags { padding-top: 0; }
  @page { margin: 0.5in; }
  .label, .tag { border: none; }
}

/* ---- v1.4: groups, notes, timeline ---- */
.pill-link { display:inline-block; background:var(--navy-soft); color:#fff; border-radius:999px;
  padding:3px 11px; font-size:12.5px; margin:3px 5px 0 0; text-decoration:none; }
.pill-link:hover { background:var(--navy); }

.note { border:1px solid var(--line); border-left:4px solid var(--gold); border-radius:8px;
  padding:11px 13px; margin-bottom:10px; background:#fff; }
.note-pastoral, .note-health { border-left-color:#C23B22; background:#FAF3F1; }
.note-prayerrequest { border-left-color:#3f7d54; }
.note-head { display:flex; gap:10px; align-items:center; font-size:12.5px; margin-bottom:5px; flex-wrap:wrap; }
.note-cat { font-weight:700; color:var(--navy); }
.note-lock { color:#C23B22; font-weight:600; }
.note-meta { color:var(--ink-soft); }
.note-body { font-size:14px; line-height:1.5; }

.timeline { list-style:none; margin:0; padding:0; }
.timeline li { display:flex; gap:12px; align-items:baseline; padding:7px 0; border-bottom:1px solid var(--line); font-size:13.5px; }
.timeline li:last-child { border-bottom:none; }
.tl-icon { width:22px; text-align:center; color:var(--gold); font-weight:700; }
.tl-date { width:120px; color:var(--ink-soft); flex-shrink:0; }
.tl-text { color:var(--ink); }

/* ---- v1.5: merge duplicates ---- */
.merge-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:16px; }
.merge-col { border:2px solid var(--line); transition:border-color .15s; }
.merge-col.merge-keep { border-color:var(--gold); }
.merge-pick { display:flex; gap:8px; align-items:center; font-weight:400; }
.merge-detail { width:100%; font-size:13.5px; }
.merge-detail td:first-child { color:var(--ink-soft); width:90px; padding:3px 0; }
.merge-counts { display:flex; flex-wrap:wrap; gap:14px; margin-top:10px; padding-top:10px; border-top:1px solid var(--line); font-size:13px; }
@media (max-width:640px){ .merge-grid{ grid-template-columns:1fr; } }

/* ---- v2.1: reports charts + previews ---- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 8px 0 4px; }
.chart-title { font-size: 12.5px; font-weight: 700; color: var(--navy-soft); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.report-preview { border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; margin-top: 10px; background: #fff; }
.report-preview table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.report-preview th, .report-preview td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13.5px; }
.report-preview th.num, .report-preview td.num { text-align: right; }
.report-preview .subhead { font-size: 12px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 2px; }
.report-preview .total-row td { font-weight: 700; border-top: 2px solid var(--navy); }
.report-preview .boiler { font-size: 11.5px; color: #555; line-height: 1.6; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 10px; }
.report-preview .addr-block { font-size: 14px; margin-bottom: 12px; }
@media (max-width: 860px) { .chart-grid { grid-template-columns: 1fr; gap: 16px; } }

/* ---- v2.4: pagination + bulk actions ---- */
.pager { display:flex; align-items:center; gap:18px; flex-wrap:wrap; margin:14px 0 4px; font-size:13.5px; }
.pager-info { color:var(--ink-soft); }
.pager-nav { display:flex; align-items:center; gap:6px; }
.pager-btn, .pager-num { padding:5px 10px; border:1px solid var(--line); border-radius:7px; background:#fff; color:var(--link); text-decoration:none; }
.pager-num { padding:5px 9px; }
.pager-num.current { background:var(--primary); border-color:var(--primary); color:#fff; font-weight:600; }
.pager-btn.disabled { color:#aab3bf; }
.pager-gap { color:#aab3bf; padding:0 2px; }
.pager-per { margin-left:auto; display:flex; align-items:center; gap:6px; color:var(--ink-soft); }
@media (max-width:640px){ .pager-per{ margin-left:0; } }

.bulk-bar { display:none; align-items:center; gap:12px; background:#EAF2FB; border:1px solid #BFD8F0; border-radius:8px; padding:8px 12px; margin-bottom:10px; font-size:13.5px; }
.bulk-bar.active { display:flex; }
.bulk-count { font-weight:600; color:var(--navy); }
td.sel, th.sel { width:34px; text-align:center; }
