:root {
  color-scheme: light;
  --primary: #9f1d2f;
  --primary-dark: #55131b;
  --accent: #0f766e;
  --accent-soft: #d9f3ee;
  --gold: #a16207;
  --ink: #181515;
  --muted: #6b6f76;
  --line: #e3e5e8;
  --panel: #ffffff;
  --bg: #f4f6f5;
  --soft: #f9faf9;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 260px),
    var(--bg);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(24, 21, 21, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 21, 21, 0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(#000, transparent 72%);
}

.app-shell {
  position: relative;
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 16px 96px;
}

.login-view {
  min-height: calc(100dvh - 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

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

.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: var(--shadow);
}
.brand-mark.invalid {
  background: linear-gradient(145deg, #7f1d1d, #450a0a);
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.08; letter-spacing: 0; }
h2 { font-size: 16px; line-height: 1.25; letter-spacing: 0; }

.muted { color: var(--muted); line-height: 1.55; }
.center { text-align: center; }
.small-text { font-size: 13px; margin-top: 4px; }
.section-gap { margin-top: 14px; }

.panel,
.pay-card,
.member-card,
.invoice-panel,
.document-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(227, 229, 232, 0.9);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

form.panel { display: grid; gap: 11px; }
label { font-size: 13px; color: #394047; font-weight: 700; }
input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

button,
.button-link {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: 0;
}
button:disabled { opacity: 0.62; cursor: wait; }
.wide { width: 100%; }

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 10px 22px rgba(159, 29, 47, 0.22);
}
.secondary {
  background: #123c39;
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.16);
}
.danger { background: var(--primary-dark); color: #fff; width: 100%; }
.button-link { background: var(--primary); color: #fff; }
.button-link.secondary { background: #123c39; color: #fff; }
.form-message { min-height: 20px; font-size: 13px; color: var(--primary); }

.hero {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(24, 21, 21, 0.96), rgba(85, 19, 27, 0.96)),
    var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 22px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--gold));
}
.hero.compact { padding: 18px; }
.hero p { opacity: 0.9; line-height: 1.45; margin-top: 8px; }

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0.78;
  margin-bottom: 8px;
}
.eyebrow.dark { color: var(--primary); opacity: 1; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.metric-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 88px;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.05);
}
.metric-grid span,
.split-row span { color: var(--muted); font-size: 13px; }
.metric-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  line-height: 1.08;
}

.section-title,
.split-row,
.member-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-title { margin-bottom: 12px; }
.split-row {
  min-height: 42px;
  border-top: 1px solid var(--line);
}
.split-row:first-of-type { border-top: 0; }
.split-row strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.check-list {
  margin: 0;
  padding-left: 18px;
  color: #394047;
  line-height: 1.6;
}

.pay-grid,
.member-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.pay-card.featured {
  border-color: rgba(159, 29, 47, 0.22);
}
.amount-xl {
  display: block;
  font-size: 30px;
  line-height: 1.05;
  margin: 8px 0 12px;
}
.inline-action,
.voluntary-form {
  display: grid;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.status-pill.paid { color: #065f46; background: #dff5ec; }
.status-pill.pending,
.status-pill.due { color: #7c2d12; background: #ffedd5; }
.status-pill.expired,
.status-pill.cancelled { color: #7f1d1d; background: #fee2e2; }
.status-pill.neutral { color: #334155; background: #eef2f7; }
.status-pill.valid { color: #065f46; background: #dff5ec; }

.invoice-list {
  display: grid;
  gap: 8px;
}
.invoice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: var(--soft);
}
.invoice-amount {
  display: grid;
  justify-items: end;
  gap: 6px;
  text-align: right;
}

.invoice-panel {
  display: grid;
  gap: 10px;
}
.qr-frame {
  width: min(100%, 320px);
  aspect-ratio: 1;
  margin: 0 auto 4px;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.qr-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.total-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  background: #181515;
  color: #fff;
  text-align: center;
}
.total-box span { color: rgba(255, 255, 255, 0.72); font-size: 13px; }
.total-box strong { font-size: 30px; line-height: 1; }

.document-card {
  display: grid;
  gap: 10px;
}
.document-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: var(--accent-soft);
}
.document-status strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}
.checksum-box {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.checksum-box span {
  color: var(--muted);
  font-size: 13px;
}
.checksum-box code {
  display: block;
  padding: 11px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.member-card { padding: 14px; }
.member-head {
  align-items: flex-start;
  padding-bottom: 12px;
}
.member-head strong {
  color: var(--accent);
  white-space: nowrap;
}
.member-code {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 4px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 720px);
  min-height: 70px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
  box-shadow: 0 -12px 30px rgba(17, 24, 39, 0.08);
}
.bottom-nav a {
  display: grid;
  place-items: center;
  color: #49515a;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}
.bottom-nav a.active {
  color: var(--primary);
  background: linear-gradient(180deg, rgba(159, 29, 47, 0.09), transparent);
}

@media (min-width: 760px) {
  .app-shell { padding-top: 28px; }
  .pay-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
