:root {
  --bg: #f1eee6;
  --paper: rgba(255, 252, 246, 0.9);
  --paper-strong: #fffdf8;
  --text: #1f241f;
  --muted: #647067;
  --border: rgba(60, 88, 64, 0.14);
  --accent: #23684b;
  --accent-soft: #ddf2e5;
  --accent-strong: #144733;
  --warm: #cb7a1d;
  --warm-soft: #fff0dc;
  --danger: #b14430;
  --danger-soft: #f6dfd7;
  --shadow: 0 20px 40px rgba(44, 51, 35, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(35, 104, 75, 0.16), transparent 26%),
    radial-gradient(circle at top right, rgba(203, 122, 29, 0.16), transparent 24%),
    linear-gradient(180deg, #f7f5ee 0%, #ece7dc 100%);
}

body.modal-open {
  overflow: hidden;
}

body[data-can-edit="0"] #detailEditButton,
body[data-can-edit="0"] #detailDepositForm,
body[data-can-edit="0"] #detailRedemptionForm,
body[data-can-edit="0"] #detailCombinedReceiptActions,
body[data-can-edit="0"] #detailDepositReceiptActions,
body[data-can-edit="0"] #detailRedemptionReceiptActions,
body[data-can-edit="0"] .entry-row-actions,
body[data-can-edit="0"] #entryEditorModal,
body[data-can-edit="0"] #resetButton,
body[data-can-edit="0"] .form-panel .form-actions {
  display: none !important;
}

body[data-can-export="0"] #detailExportButton {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1260px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.brand-banner {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.brand-logo {
  display: block;
  max-width: min(182px, 39vw);
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(44, 51, 35, 0.12));
}

.top-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
  align-items: stretch;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 14px;
  text-decoration: none;
  text-align: center;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
}

.nav-link.active {
  background: var(--accent);
  color: #fff;
}

.language-switch {
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  margin: 0 auto 16px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--paper-strong);
}

.language-switch button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.language-switch button.active {
  background: var(--accent);
  color: #fff;
}

.hero {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero,
.panel,
.member-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero,
.panel {
  padding: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 700;
}

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

h1 {
  font-size: clamp(2rem, 3vw, 3.5rem);
  line-height: 1.05;
  max-width: 13ch;
  margin-bottom: 12px;
}

.hero-copy {
  max-width: 64ch;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 0;
}

.compact-hero h1 {
  max-width: 16ch;
}

.compact-hero:not(:has(.hero-panel)) {
  grid-template-columns: 1fr;
}

.compact-hero:not(:has(.hero-panel)) h1 {
  max-width: 100%;
}

.hero-panel {
  display: grid;
  gap: 16px;
}

.stat,
.summary-card {
  background: var(--paper-strong);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
}

.stat-label,
.summary-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat strong,
.summary-card strong {
  font-size: 2rem;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 410px) 1fr;
  gap: 24px;
}

body[data-edit-member="1"] .dashboard {
  grid-template-columns: minmax(0, 820px);
  justify-content: center;
}

body[data-edit-member="1"] .list-panel {
  display: none;
}

.dashboard-summary-panel {
  grid-column: 1 / -1;
}

.dashboard-kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.9fr);
  gap: 16px;
}

.dashboard-search-card {
  align-content: start;
}

.dashboard-search-results {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.dashboard-search-result {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--paper-strong);
  border: 1px solid var(--border);
}

.dashboard-search-result > div:first-child {
  min-width: 0;
}

.dashboard-actions-card {
  margin-top: 16px;
}

.dashboard-action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-action-grid .secondary-button {
  justify-content: center;
  text-align: center;
}

.member-health-panel {
  margin-bottom: 18px;
}

.member-health-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 0;
}

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

.section-heading h2 {
  margin-bottom: 0;
}

.compact-heading {
  margin-bottom: 12px;
}

.member-form,
.toolbar,
.deposit-form,
.redemption-form,
.catalog-form {
  display: grid;
  gap: 16px;
}

.photo-upload-block {
  display: grid;
  gap: 14px;
}

.document-upload-block {
  display: grid;
  gap: 14px;
}

.photo-preview-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.photo-preview.show {
  display: block;
}

.photo-preview-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.photo-preview-fallback.hide {
  display: none;
}

.member-form label,
.toolbar-field,
.deposit-form label,
.redemption-form label,
.catalog-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.required-label::after {
  content: " *";
  color: var(--danger);
  font-weight: 800;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(60, 88, 64, 0.18);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(35, 104, 75, 0.12);
  transform: translateY(-1px);
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}

.password-field input {
  display: block;
  padding-right: 48px;
}

.password-field input:focus {
  transform: none;
}

.password-toggle {
  position: absolute;
  top: 5px;
  right: 10px;
  bottom: 5px;
  width: 34px;
  height: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: none;
  z-index: 1;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: rgba(35, 104, 75, 0.1);
  color: var(--accent-strong);
  outline: none;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.form-actions,
.member-actions,
.entry-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.action-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 12px 18px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.action-button:hover {
  transform: translateY(-1px);
}

.bank-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.module-divider {
  height: 1px;
  background: rgba(60, 88, 64, 0.12);
  margin: 26px 0;
}

.item-modules {
  display: grid;
  gap: 16px;
}

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

.item-management-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.item-management-dashboard,
.item-management-dashboard .item-management-grid {
  grid-template-columns: 1fr;
}

.module-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(60, 88, 64, 0.1);
}

.module-card h3 {
  margin-bottom: 12px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--paper-strong);
  border: 1px solid var(--border);
}

.chip button {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
}

.toolbar {
  grid-template-columns: 1fr;
  margin-bottom: 18px;
}

.page-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.member-cards {
  display: grid;
  gap: 18px;
}

.list-page-panel {
  padding: 28px;
}

.member-card {
  padding: 20px;
}

.member-card-header,
.member-card-top,
.member-card-metrics {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: start;
}

.member-card-header {
  margin-bottom: 18px;
}

.member-identity {
  display: flex;
  gap: 16px;
  align-items: center;
}

.member-avatar,
.member-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  flex-shrink: 0;
}

.member-avatar {
  object-fit: cover;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.member-avatar-placeholder {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 800;
}

.member-card-top {
  align-items: center;
  margin-bottom: 14px;
}

.member-name {
  margin-bottom: 6px;
}

.member-subtitle,
.small-text,
.entry-meta,
.note-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.badge.Active {
  background: #ddf4ea;
  color: #116149;
}

.badge.Pending {
  background: #fff0d9;
  color: #8a5800;
}

.badge.Inactive {
  background: #ece7e2;
  color: #6a6259;
}

.member-card-metrics {
  margin: 16px 0;
  flex-wrap: wrap;
}

.metric-box {
  flex: 1 1 120px;
  min-width: 120px;
  padding: 14px;
  border-radius: 18px;
  background: var(--paper-strong);
  border: 1px solid var(--border);
}

.metric-box span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-box strong {
  font-size: 1.45rem;
}

.metric-box.redeemed {
  background: var(--danger-soft);
}

.metric-box.balance {
  background: var(--warm-soft);
}

.member-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.card-section {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(60, 88, 64, 0.1);
}

.card-section h4 {
  margin-bottom: 12px;
}

.detail-list {
  display: grid;
  gap: 10px;
}

.detail-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.entry-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.entry-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--paper-strong);
  border: 1px solid var(--border);
}

.entry-row > div:first-child {
  min-width: 0;
}

.entry-points {
  color: var(--warm);
  font-weight: 800;
  white-space: nowrap;
}

.entry-points.redeemed {
  color: var(--danger);
}

.entry-row-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.entry-row-actions {
  justify-content: flex-end;
}

.entry-select {
  display: inline-flex;
  align-items: center;
  margin-bottom: 8px;
}

.entry-select input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
}

#detailCombinedReceiptActions,
#detailDepositReceiptActions,
#detailRedemptionReceiptActions {
  margin-top: 10px;
}

#detailCombinedReceiptActions {
  justify-content: center;
}

#detailPrintCombinedReceiptButton,
#detailPrintReceiptButton,
#detailPrintRedemptionReceiptButton {
  background: var(--warm);
  color: #fff;
}

.deposit-form,
.redemption-form {
  margin-top: 10px;
}

.entry-actions {
  justify-content: flex-end;
}

.action-button {
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.action-button.edit {
  background: rgba(35, 104, 75, 0.12);
  color: var(--accent-strong);
}

.action-button.delete {
  background: rgba(177, 68, 48, 0.12);
  color: var(--danger);
}

.custom-receipt-form {
  gap: 16px;
}

.custom-receipt-table th,
.custom-receipt-table td {
  vertical-align: middle;
}

.custom-receipt-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.custom-receipt-total-input {
  background: #f6f2ea;
  font-weight: 700;
}

.custom-receipt-footer {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.custom-receipt-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.custom-receipt-actions .primary-button,
.custom-receipt-actions .secondary-button,
.custom-receipt-actions .ghost-button {
  white-space: nowrap;
}

.custom-receipt-total-card {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(241, 238, 230, 0.95), rgba(255, 255, 255, 0.98));
}

.custom-receipt-total-card strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1.1;
  margin-top: 6px;
  color: var(--accent-strong);
}

.dual-history {
  display: grid;
  gap: 16px;
}

.subsection-title {
  margin-bottom: 8px;
}

.empty-history {
  color: var(--muted);
  padding: 12px 0 2px;
}

.empty-state {
  display: none;
  text-align: center;
  padding: 28px 16px 8px;
  color: var(--muted);
}

.empty-state.show {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 36, 31, 0.46);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--paper-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
  animation: modal-rise 180ms ease;
}

@keyframes modal-rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.status-banner {
  padding: 12px 14px;
  border-radius: 16px;
  margin-bottom: 16px;
  font-weight: 600;
}

.status-banner.info {
  background: #eef4f0;
  color: var(--ink);
  border: 1px solid var(--border);
}

.status-banner.success {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(35, 104, 75, 0.16);
}

.status-banner.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(177, 68, 48, 0.16);
}

.form-status-banner {
  margin-top: 14px;
  margin-bottom: 0;
}

.member-table th,
.member-table td {
  white-space: nowrap;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: rgba(35, 104, 75, 0.08);
}

.member-table td.wrap-cell {
  white-space: normal;
}

.member-detail-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
}

.detail-hero-title {
  display: flex;
  gap: 16px;
  align-items: center;
}

.report-layout {
  display: grid;
  gap: 24px;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.report-go-wrap {
  display: flex;
  align-items: end;
}

.chart-surface {
  min-height: 320px;
  display: grid;
  place-items: center;
}

.bar-chart-legend {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.bar-chart {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 14px;
  align-items: end;
}

.bar-chart-item {
  display: grid;
  gap: 10px;
  align-items: end;
  text-align: center;
}

.bar-chart-value,
.bar-chart-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.bar-chart-meta {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.bar-chart-bar-wrap {
  min-height: 200px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 6px;
}

.bar-chart-bar-group {
  align-items: end;
  border-bottom: 1px solid rgba(60, 88, 64, 0.16);
  padding-bottom: 6px;
}

.bar-chart-bar {
  width: 18px;
  border-radius: 16px 16px 8px 8px;
  background: linear-gradient(180deg, #4f9e78 0%, #23684b 100%);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.06);
}

.bar-chart-series {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 18px;
  grid-template-rows: 20px 1fr 92px;
  height: 100%;
}

.bar-chart-series-value,
.bar-chart-series-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.bar-chart-series-value {
  min-height: 20px;
}

.bar-chart-series-bar-wrap {
  width: 100%;
  min-height: 180px;
  display: flex;
  align-items: end;
  justify-content: center;
}

.bar-chart-series-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 92px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.pie-chart-layout {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 24px;
  align-items: center;
}

.pie-chart-svg {
  width: 100%;
  max-width: 320px;
  height: auto;
}

.pie-legend {
  display: grid;
  gap: 10px;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.pie-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex-shrink: 0;
}

@media (max-width: 1080px) {
  .hero,
  .dashboard,
  .member-grid,
  .bank-summary,
  .dashboard-management-grid,
  .dashboard-action-grid,
  .member-health-grid,
  .member-detail-layout {
    grid-template-columns: 1fr;
  }

  .module-grid,
  .item-management-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .toolbar,
  .deposit-grid,
  .redemption-grid,
  .report-filters,
  .pie-chart-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1260px);
    padding-top: 18px;
  }

  .hero,
  .panel,
  .member-card {
    border-radius: 22px;
  }

  .hero,
  .panel,
  .member-card {
    padding: 18px;
  }

  .form-grid,
  .section-heading {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .member-card-header,
  .member-card-top {
    flex-direction: column;
  }

  .top-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    max-width: 100%;
  }
}
