/* ====================================================================
   Church+ — application stylesheet
   Palette: sanctuary navy, vestment gold, hymnal cream
   ==================================================================== */
:root {
  --navy:        #14274a;
  --navy-deep:   #0d1b34;
  --navy-soft:   #2b416b;
  --gold:        #c9a227;
  --gold-soft:   #efe3b8;
  --cream:       #faf7f0;
  --paper:       #ffffff;
  --ink:         #20262e;
  --ink-soft:    #5b6470;
  --line:        #e4ded2;
  --green:       #2f7d4f;
  --red:         #b3382f;
  --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(--navy); }

/* -- Top bar ---------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--navy-deep);
  color: #fff;
  padding: 0 22px;
  height: 58px;
  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: 34px; 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: rgba(255,255,255,.85); }
.role-pill {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  background: rgba(201,162,39,.18); color: var(--gold);
  border: 1px solid rgba(201,162,39,.5);
  padding: 2px 9px; border-radius: 99px;
}

/* -- Layout ------------------------------------------------------------ */
.layout { display: flex; min-height: calc(100vh - 58px); }
.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(--navy-soft); color: #fff; }
.nav-link.active {
  background: var(--navy-soft); 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(--navy); color: #fff;
}
.btn:hover { background: var(--navy-soft); }
.btn-gold { background: var(--gold); color: var(--navy-deep); }
.btn-gold:hover { background: #b8941f; }
.btn-outline { background: transparent; color: var(--navy); border-color: var(--navy-soft); }
.btn-outline:hover { background: #eef0f5; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #93291f; }
.btn-ghost { background: transparent; color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.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: #fdf3d7; color: #8a6d10; }
.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: #ecf6ef; border-color: #bcdcc7; color: var(--green); }
.flash-error   { background: #fbeeec; border-color: #ecc8c4; color: var(--red); }

/* -- 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) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
  .nav-label { display: none; }
  .nav-link { padding: 7px 11px; }
  .content { padding: 18px 16px 50px; }
  .field.span-2 { grid-column: span 1; }
}
@media print {
  .topbar, .sidebar, .btn, .search-bar { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}

/* ====================================================================
   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: #14274a; }
.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:#b3382f; background:#fdf6f5; }
.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:#b3382f; 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; } }
