:root {
  --navy: #083c7c;
  --blue: #0b4ea2;
  --teal: #0f766e;
  --gold: #c7952d;
  --gold-soft: #fff7df;
  --green: #167a3b;
  --red: #b42318;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #d7dde8;
  --soft: #f4f7fb;
  --white: #ffffff;
  --danger: #b42318;
  --warn: #fff7cc;
  --ok: #dcfce7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, rgba(252, 209, 22, .08), transparent 220px),
    var(--soft);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: var(--white);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
}

button:hover {
  background: var(--navy);
}

button.ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, .45);
}

button.secondary {
  background: var(--teal);
}

button.warning {
  background: var(--gold);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  background: var(--gold);
  color: var(--white);
  padding: 10px 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.button-link:hover {
  background: #a77922;
}

.notice {
  border: 1px solid rgba(199, 149, 45, .42);
  border-left: 5px solid var(--gold);
  background: var(--gold-soft);
  color: #5f4312;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 14px 0;
  line-height: 1.45;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--white);
  max-width: 100%;
}

textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--white);
  font: inherit;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin: 10px 0 5px;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f2f57 0%, #2563a8 48%, #0f766e 100%);
  padding: 24px;
}

.home-screen,
.member-screen {
  min-height: 100vh;
  background: var(--soft);
}

.home-header {
  background:
    linear-gradient(90deg, rgba(199, 149, 45, .22), transparent 32%),
    var(--navy);
  color: var(--white);
  padding: 18px 24px;
  box-shadow: 0 3px 14px rgba(15, 47, 87, .18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.home-main {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.home-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-top: 4px solid var(--gold);
}

.home-card p {
  color: var(--muted);
  line-height: 1.45;
}

.login-panel {
  width: min(440px, 96vw);
  background: var(--white);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(15, 47, 87, .32);
}

.login-panel h1 {
  margin: 14px 0 18px;
  color: var(--navy);
  font-size: 24px;
}

.login-panel button {
  width: 100%;
  margin-top: 16px;
}

.login-panel .back-button {
  margin-top: 8px;
  background: #e5e7eb;
  color: var(--ink);
}

#loginMessage {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
}

.church-mark {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fef3c7;
  color: var(--navy);
  border: 3px solid #d8a31f;
  font-weight: 800;
  letter-spacing: .04em;
}

.church-mark.small {
  width: 54px;
  height: 54px;
  font-size: 15px;
}

.topbar {
  min-height: 92px;
  background:
    linear-gradient(90deg, rgba(199, 149, 45, .24), transparent 38%),
    var(--blue);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  color: var(--white);
}

.brand p,
.user-box span {
  margin: 4px 0 0;
  color: #dbeafe;
  font-size: 13px;
}

.user-box {
  text-align: right;
  display: grid;
  justify-items: end;
  gap: 7px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - 92px);
}

.sidebar {
  background: var(--navy);
  color: var(--white);
  border-top: 1px solid rgba(255, 255, 255, .16);
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  padding: 10px 18px;
  overflow-x: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subnav {
  background: #f9fbff;
  border-bottom: 1px solid var(--line);
  padding: 10px 18px;
  overflow-x: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 5px 18px rgba(15, 47, 87, .05);
}

.sidebar-heading,
.subnav-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0 8px 0 0;
  white-space: nowrap;
}

.sidebar-heading {
  color: #f9e4ad;
}

.subnav-title {
  color: var(--gold);
}

.nav-module,
.subnav-button {
  width: auto;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 7px;
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.nav-module {
  background: transparent;
  color: var(--white);
}

.nav-module:hover,
.nav-module.active {
  background: linear-gradient(90deg, rgba(199, 149, 45, .28), rgba(11, 78, 162, .96));
  color: var(--white);
  border-color: rgba(255, 255, 255, .2);
  box-shadow: inset 3px 0 0 var(--gold);
}

.nav-module b {
  color: #f9e4ad;
  font-size: 15px;
  line-height: 1;
}

.subnav-button {
  background: transparent;
  color: var(--navy);
}

.subnav-button:hover,
.subnav-button.active {
  background: var(--white);
  border-color: #e3d4ad;
  color: var(--blue);
  box-shadow: inset 3px 0 0 var(--gold), 0 6px 18px rgba(15, 47, 87, .07);
}

.main {
  padding: 22px;
  overflow: auto;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background:
    linear-gradient(90deg, rgba(199, 149, 45, .16), transparent 42%),
    var(--white);
  border: 1px solid #e3d4ad;
  border-left: 7px solid var(--gold);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(15, 47, 87, .08);
}

.dashboard-kicker {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}

.dashboard-hero h1 {
  margin: 0;
  color: var(--navy);
  font-size: 28px;
  line-height: 1.15;
}

.dashboard-hero p {
  margin: 8px 0 0;
  color: #475569;
  line-height: 1.45;
}

.dashboard-church-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 190px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.page-title {
  margin: 0 0 16px;
  color: var(--navy);
  font-size: 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.dashboard-grid {
  margin-bottom: 18px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.module-card {
  background: var(--white);
  border: 1px solid #e3d4ad;
  border-top: 4px solid var(--gold);
  border-radius: 10px;
  padding: 18px;
  display: grid;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(15, 47, 87, .08);
}

.module-card span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.module-card strong {
  color: var(--navy);
  line-height: 1.35;
}

.module-card button {
  width: fit-content;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
}

.stat,
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.stat {
  border-top: 4px solid var(--gold);
  position: relative;
  min-height: 128px;
}

.stat::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold-soft);
  border: 1px solid rgba(199, 149, 45, .45);
}

.stat.stat-green { border-top-color: var(--green); }
.stat.stat-red { border-top-color: var(--red); }
.stat.stat-blue { border-top-color: var(--blue); }
.stat.stat-teal { border-top-color: var(--teal); }
.stat.stat-gold { border-top-color: var(--gold); }

.stat strong {
  display: block;
  font-size: 29px;
  color: var(--navy);
  margin: 8px 0 3px;
}

.stat span {
  color: #334155;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.stat em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.dashboard-panel {
  border-top: 4px solid var(--gold);
}

.panel {
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 18px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar > * {
  flex: 1 1 210px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions button {
  width: auto;
  padding: 8px 10px;
  white-space: nowrap;
}

.stat-mini {
  border: 1px solid #e3d4ad;
  border-radius: 7px;
  background: var(--gold-soft);
  color: #6d4b0f;
  font-size: 13px;
  font-weight: 900;
  padding: 9px 12px;
  white-space: nowrap;
}

.collection-panel {
  border-top: 4px solid var(--gold);
}

.collection-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.collection-presets button {
  width: auto;
  min-width: 150px;
}

.import-panel {
  border-top: 4px solid var(--gold);
}

.import-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.upload-box {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px dashed #b9c4d6;
  border-radius: 10px;
  background: #fbfdff;
  padding: 14px;
}

.upload-box input[type="file"] {
  background: var(--white);
}

.import-stats {
  margin-bottom: 16px;
}

.warn-text {
  color: #92400e;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #e8edf5;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: var(--blue);
  color: var(--white);
  position: sticky;
  top: 0;
}

tr:hover td {
  background: #fbfdff;
}

.money {
  text-align: right;
  white-space: nowrap;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.active {
  background: var(--ok);
  color: #166534;
}

.pill.inactive {
  background: var(--warn);
  color: #92400e;
}

.pill.non {
  background: #fee2e2;
  color: #991b1b;
}

.warning-row td {
  background: var(--warn);
}

.profile-head {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 14px;
}

.person-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.person {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.person strong {
  display: block;
  color: var(--navy);
  margin-bottom: 5px;
}

.small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
}

.message {
  min-height: 20px;
  font-weight: 700;
  color: var(--teal);
}

.member-portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.member-topbar {
  background:
    linear-gradient(90deg, rgba(199, 149, 45, .24), transparent 38%),
    var(--blue);
  color: var(--white);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 6px 18px rgba(9, 32, 65, .18);
}

.church-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.church-logo {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff7d8, #ffffff);
  border: 4px solid var(--gold);
  object-fit: cover;
  object-position: center;
  padding: 3px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .86), 0 8px 22px rgba(0, 0, 0, .2);
  flex: 0 0 auto;
}

.church-picture {
  width: 112px;
  height: 112px;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff7d8, #ffffff);
  border: 5px solid var(--gold);
  padding: 4px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .86), 0 10px 24px rgba(0, 0, 0, .22);
  flex: 0 0 auto;
}

.header-picture {
  width: 118px;
  height: 118px;
}

.compact-picture {
  width: 64px;
  height: 64px;
  border-width: 3px;
  padding: 3px;
}

.dashboard-picture {
  width: 148px;
  height: 148px;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px #fff, 0 12px 30px rgba(15, 47, 87, .2);
}

.header-logo {
  width: 64px;
  height: 64px;
}

.login-logo {
  width: 96px;
  height: 96px;
  display: block;
  margin: 0 auto 14px;
}

.church-title {
  font-size: 25px;
  line-height: 1.15;
  font-weight: 800;
  margin: 0;
  color: var(--white);
}

.church-meta {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, .9);
}

.member-main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.member-hero {
  background: var(--white);
  border: 1px solid #d9e4f2;
  border-radius: 12px;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(15, 42, 75, .08);
  margin-bottom: 18px;
}

.member-kicker {
  font-size: 13px;
  font-weight: 800;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.member-name {
  font-size: 34px;
  line-height: 1.12;
  font-weight: 900;
  color: #0f2344;
  margin: 0;
}

.member-subtitle {
  font-size: 16px;
  color: #526173;
  margin-top: 8px;
  line-height: 1.5;
}

.member-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.member-badge {
  background: #eef5ff;
  border: 1px solid #cfe1fb;
  color: var(--blue);
  border-radius: 6px;
  padding: 10px 12px;
  font-weight: 800;
  white-space: nowrap;
}

.member-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  align-items: start;
}

.member-card {
  background: var(--white);
  border: 1px solid #d9e4f2;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(15, 42, 75, .07);
  padding: 20px;
  min-width: 0;
}

.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.member-card h2 {
  margin: 0 0 14px;
  font-size: 19px;
  color: var(--blue);
}

.info-list,
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.info-item,
.member-stat {
  border: 1px solid #e4ebf4;
  background: #f8fbff;
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.info-label,
.member-stat span {
  display: block;
  font-size: 12px;
  color: #66758a;
  font-weight: 800;
  margin-bottom: 5px;
}

.info-value {
  font-size: 16px;
  color: #172033;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.member-stat strong {
  display: block;
  color: #0f2344;
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.member-stat.due strong { color: var(--danger); }
.member-stat.paid strong { color: #157347; }

.scripture-card {
  border-color: #d7e8dc;
}

.scripture-card h2,
.scripture-reference {
  color: #1f6b3a;
}

.scripture-label {
  display: inline-block;
  background: #eef8f0;
  color: #1f6b3a;
  border: 1px solid #cfe7d4;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 12px;
}

.scripture-quote {
  font-size: 18px;
  line-height: 1.45;
  color: #17351f;
  font-weight: 800;
  margin: 0 0 10px;
}

.giving-note {
  margin: 12px 0 0;
  border-left: 4px solid #1f6b3a;
  background: #f4fbf6;
  color: #24472d;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 700;
}

.portal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.portal-form button {
  grid-column: 1 / -1;
  min-height: 42px;
  font-weight: 800;
}

.portal-message {
  min-height: 20px;
  margin: 12px 0 0;
}

.error {
  color: var(--danger);
  font-weight: 800;
}

.payments-empty {
  color: #526173;
  font-weight: 700;
  padding: 10px 0;
}

.site-footer {
  background: #062f61;
  color: #eaf2ff;
  border-top: 4px solid var(--gold);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}

.site-footer strong {
  color: var(--white);
  font-size: 14px;
}

.site-footer span {
  color: #dbeafe;
}

.compact-footer {
  margin-top: 18px;
  border-radius: 8px;
  border-top-width: 3px;
  padding: 12px;
  background: #f8fafc;
  color: #334155;
}

.compact-footer strong,
.compact-footer span {
  color: #334155;
}

@media (max-width: 820px) {
  .home-header,
  .topbar,
  .brand {
    align-items: flex-start;
  }

  .home-header,
  .topbar,
  .layout,
  .dashboard-hero {
    display: block;
  }

  .home-header .church-picture,
  .topbar .church-picture,
  .member-topbar .church-picture {
    margin-top: 14px;
  }

  .dashboard-church-card {
    justify-items: start;
    text-align: left;
    margin-top: 16px;
  }

  .dashboard-hero h1 {
    font-size: 24px;
  }

  .sidebar {
    display: flex;
    overflow: auto;
    gap: 8px;
  }

  .subnav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-heading,
  .subnav-title {
    min-width: max-content;
    align-self: center;
    margin: 0 8px 0 0;
  }

  .nav-module,
  .subnav-button {
    min-width: 155px;
  }

  .section-head {
    display: block;
  }

  .profile-head {
    grid-template-columns: 1fr;
  }

  .import-head,
  .upload-box {
    display: block;
  }

  .upload-box .actions {
    margin-top: 12px;
  }

  .member-portal-grid {
    grid-template-columns: 1fr;
  }

  .member-topbar,
  .member-hero {
    display: block;
  }

  .member-name {
    font-size: 28px;
  }

  .member-badges {
    justify-content: flex-start;
    margin-top: 16px;
  }

  .span-4,
  .span-6,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }

  .info-list,
  .stat-row,
  .portal-form {
    grid-template-columns: 1fr;
  }
}
