:root {
  --bg: #f6f4ed;
  --surface: #ffffff;
  --surface-soft: #fff8e6;
  --ink: #201b16;
  --muted: #70675c;
  --line: #ddd2c1;
  --accent: #8e2f1f;
  --accent-dark: #642115;
  --gold: #c4932e;
  --green: #1d6d4f;
  --red: #a52920;
  --shadow: 0 16px 40px rgba(64, 45, 28, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 248, 230, 0.88), rgba(246, 244, 237, 0.96)),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: 112px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-header {
  background: var(--accent);
  color: #fffdf6;
  border-bottom: 4px solid var(--gold);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 28px 18px 30px;
}

.header-logo {
  width: clamp(76px, 18vw, 132px);
  height: clamp(76px, 18vw, 132px);
  flex: 0 0 auto;
  object-fit: contain;
  background: #fffdf6;
  border: 3px solid #ffe4a6;
  border-radius: 50%;
  box-shadow: 0 12px 28px rgba(32, 27, 22, 0.18);
}

.eyebrow {
  margin: 0 0 6px;
  color: #ffe4a6;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--accent);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 13ch;
  margin-bottom: 6px;
  font-size: clamp(2rem, 6vw, 3.7rem);
  line-height: 1;
  letter-spacing: 0;
}

.subtitle {
  margin-bottom: 0;
  color: #ffe8bd;
  font-size: 1rem;
}

.page-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  background: rgba(246, 244, 237, 0.96);
  backdrop-filter: blur(12px);
}

.filter-button,
.primary-button,
.quantity-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.filter-button {
  flex: 0 0 auto;
  padding: 0 18px;
  color: var(--accent-dark);
  background: #fffdf6;
  border: 1px solid var(--line);
}

.filter-button.is-active {
  color: #fffdf6;
  background: var(--accent);
  border-color: var(--accent);
}

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

.seva-card {
  display: flex;
  flex-direction: column;
  min-height: 214px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(64, 45, 28, 0.07);
}

.seva-card.is-selected {
  border-color: var(--gold);
  box-shadow: 0 10px 26px rgba(142, 47, 31, 0.16);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.category-pill {
  flex: 0 0 auto;
  padding: 5px 9px;
  color: var(--accent-dark);
  background: var(--surface-soft);
  border: 1px solid #f0d99e;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
}

.seva-name {
  margin: 12px 0 8px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.seva-description {
  flex: 1;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.amount {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 900;
  white-space: nowrap;
}

.quantity-row {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 10px;
}

.quantity-button {
  color: var(--accent-dark);
  background: #f4ead5;
  font-size: 1.45rem;
}

.quantity-value {
  display: grid;
  min-height: 48px;
  place-items: center;
  color: var(--ink);
  background: #faf7ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
}

.sticky-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 246, 0.98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 28px rgba(64, 45, 28, 0.12);
}

.footer-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

#totalAmount {
  font-size: 1.35rem;
}

.primary-button {
  min-width: 156px;
  padding: 0 18px;
  color: #fffdf6;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(142, 47, 31, 0.22);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  color: #9f988e;
  background: #ded7cc;
  box-shadow: none;
}

.full-width {
  width: 100%;
}

.devotee-panel,
.result-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: end center;
  padding: 18px;
  background: rgba(32, 27, 22, 0.48);
}

.devotee-panel.is-open,
.result-screen.is-open {
  display: grid;
}

.panel-card,
.result-card {
  width: min(520px, 100%);
  padding: 22px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-card {
  position: relative;
}

.panel-card h2,
.result-card h2 {
  margin-bottom: 18px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  color: var(--muted);
  background: #f5efe3;
}

form {
  display: grid;
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196, 147, 46, 0.18);
}

.form-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 700;
}

.result-label {
  margin-bottom: 8px;
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.result-card.is-failed .result-label {
  color: var(--red);
}

.result-card p {
  color: var(--muted);
}

.receipt-view {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  color: var(--ink);
}

.receipt-summary {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #fff8e6;
  border: 1px solid #f0d99e;
  border-radius: 8px;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.receipt-line strong {
  text-align: right;
}

.receipt-items {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.receipt-items li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.receipt-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 24px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.history-section {
  margin-top: 30px;
  padding: 18px;
  background: rgba(255, 253, 246, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.history-header h2 {
  margin-bottom: 0;
  font-size: 1.4rem;
  line-height: 1.18;
}

.history-layout {
  display: grid;
  gap: 14px;
}

.history-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}

.is-hidden {
  display: none;
}

.history-results {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.history-card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(64, 45, 28, 0.06);
}

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

.history-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.history-meta,
.history-items {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.status-pill {
  flex: 0 0 auto;
  padding: 6px 9px;
  color: #fffdf6;
  background: var(--muted);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.paid {
  background: var(--green);
}

.status-pill.failed {
  background: var(--red);
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.secondary-button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--accent-dark);
  background: #f4ead5;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

@media (min-width: 720px) {
  body {
    padding-bottom: 112px;
  }

  .header-inner {
    gap: 24px;
    padding: 38px 22px 42px;
  }

  h1 {
    max-width: none;
  }

  .page-shell {
    padding: 22px;
  }

  .history-section {
    padding: 22px;
  }

  .history-layout {
    grid-template-columns: 1fr 1fr;
  }

  .devotee-panel,
  .result-screen {
    place-items: center;
  }

  .sticky-footer {
    padding-right: max(22px, calc((100vw - 1080px) / 2 + 22px));
    padding-left: max(22px, calc((100vw - 1080px) / 2 + 22px));
  }
}
