:root {
  --bg: #12100d;
  --panel: #1c1916;
  --panel-2: #262119;
  --line: #3a3229;
  --gold: #c9a227;
  --gold-soft: #e3c765;
  --text: #f2ece1;
  --muted: #a1958180;
  --muted-solid: #a19581;
  --green: #4c9a5a;
  --red: #b4483c;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px; letter-spacing: -0.5px;
}
.brand-text { min-width: 0; }
.brand-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px; letter-spacing: 0.3px; line-height: 1.1;
}
.brand-sub {
  font-size: 11px; color: var(--muted-solid);
  text-transform: uppercase; letter-spacing: 1.1px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------- generic ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 14px; }

h2 { font-family: Georgia, serif; font-weight: 500; font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted-solid); font-size: 14px; margin: 0 0 16px; line-height: 1.45; }

button {
  font: inherit;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 15px 18px;
  cursor: pointer;
  transition: filter .15s, opacity .15s;
  touch-action: manipulation;
}
button:active { filter: brightness(.9); }
button:disabled { opacity: .5; cursor: default; }

.btn-primary {
  width: 100%;
  background: var(--gold);
  color: #1a1408;
  font-weight: 650;
  letter-spacing: .2px;
}
.btn-secondary {
  width: 100%;
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost {
  background: transparent; border: none; color: var(--muted-solid);
  font-size: 14px; padding: 10px;
}
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn-small {
  padding: 9px 13px; font-size: 13px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}

label { display: block; font-size: 13px; color: var(--muted-solid); margin-bottom: 7px;
        text-transform: uppercase; letter-spacing: .8px; }

input[type=text], input[type=tel], input[type=number], input[type=password], select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 11px;
  padding: 15px 16px;
  font: inherit;
  outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
input::placeholder { color: #6f6558; }

.field + .field { margin-top: 14px; }

/* ---------- screens ---------- */
.screen { display: none; animation: fade .18s ease; flex: 1; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- scanner ---------- */
#reader {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  min-height: 240px;
}
#reader video { width: 100% !important; display: block; }
.scan-hint {
  text-align: center; color: var(--muted-solid); font-size: 13px;
  margin: 12px 0 2px; line-height: 1.5;
}
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted-solid); font-size: 12px;
  text-transform: uppercase; letter-spacing: 1px;
  margin: 20px 0 16px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ---------- member card ---------- */
.member-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.avatar {
  width: 56px; height: 56px; flex: none; border-radius: 50%;
  background: var(--panel-2); border: 1.5px solid var(--gold);
  display: grid; place-items: center;
  font-family: Georgia, serif; font-size: 20px; color: var(--gold-soft);
}
.member-name { font-family: Georgia, serif; font-size: 21px; line-height: 1.2; }
.member-code { font-size: 13px; color: var(--muted-solid); margin-top: 3px; letter-spacing: .5px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 13px 14px;
}
.stat-label { font-size: 11px; color: var(--muted-solid); text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 19px; margin-top: 5px; font-family: Georgia, serif; }
.stat-value.low { color: var(--red); }

.pill {
  display: inline-block; padding: 5px 11px; border-radius: 999px;
  font-size: 12px; letter-spacing: .5px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted-solid);
}
.pill.ok { color: var(--green); border-color: #2f5c38; background: #16281a; }
.pill.warn { color: var(--gold-soft); border-color: #5c4c1c; background: #2a2410; }

/* ---------- success ---------- */
.success-mark {
  width: 72px; height: 72px; margin: 6px auto 16px;
  border-radius: 50%; display: grid; place-items: center;
  background: #16281a; border: 2px solid var(--green);
  color: var(--green); font-size: 34px;
}
.center { text-align: center; }

/* ---------- amounts ---------- */
.amount-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.amount-btn {
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 16px 6px; font-size: 17px;
  font-family: Georgia, serif; border-radius: 11px;
}
.amount-btn.selected { border-color: var(--gold); background: #2e2712; color: var(--gold-soft); }

#card-container {
  background: #fff; border-radius: 11px; padding: 4px 12px; min-height: 56px;
}
.sandbox-note {
  margin-top: 12px; font-size: 12px; color: var(--muted-solid);
  background: var(--panel-2); border: 1px dashed var(--line);
  border-radius: 9px; padding: 11px 13px; line-height: 1.6;
}
.sandbox-note code { color: var(--gold-soft); font-size: 12px; }

/* ---------- misc ---------- */
.msg { border-radius: 10px; padding: 13px 15px; font-size: 14px; margin-bottom: 14px; line-height: 1.5; }
.msg.error { background: #2c1512; border: 1px solid #6b2c24; color: #f0b6ae; }
.msg.info  { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted-solid); }
.hidden { display: none !important; }

.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row .meta { font-size: 13px; color: var(--muted-solid); margin-top: 3px; }
.list-main { min-width: 0; }
.list-title { font-size: 16px; }

.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.25); border-top-color: #1a1408;
  display: inline-block; vertical-align: -3px; margin-right: 9px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer-link { text-align: center; margin-top: auto; padding-top: 22px; }
.footer-link a { color: var(--muted-solid); font-size: 13px; text-decoration: none; }

/* ---------- membership expiry ---------- */
.expiry {
  margin-top: 12px; padding: 12px 14px; border-radius: 11px;
  font-size: 14px; line-height: 1.45;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted-solid);
}
.expiry.ok      { border-color: #2f5c38; background: #16281a; color: #8fce9c; }
.expiry.soon    { border-color: #5c4c1c; background: #2a2410; color: var(--gold-soft); }
.expiry.expired { border-color: #6b2c24; background: #2c1512; color: #f0b6ae; }
.expiry strong  { font-weight: 650; }

/* ---------- meeting rows ---------- */
.row-actions { display: flex; gap: 6px; flex: none; align-items: center; }
.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted-solid);
  border-radius: 9px; padding: 8px 11px; font-size: 14px; line-height: 1;
}
.icon-btn.danger { color: #d98a80; border-color: #5a2c26; }
.cost-tag { color: var(--gold-soft); }

/* ---------- meeting admission fee toggle ---------- */
.fee-box {
  margin-top: 12px; padding: 14px; border-radius: 11px;
  background: #2a2410; border: 1px solid #5c4c1c;
}
.fee-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.fee-title { font-size: 16px; color: var(--gold-soft); }
.fee-note { font-size: 12.5px; color: var(--muted-solid); margin-top: 3px; line-height: 1.4; }

.switch { position: relative; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  display: block; width: 50px; height: 30px; border-radius: 999px;
  background: #3a3229; border: 1px solid var(--line); transition: background .18s;
}
.switch-thumb {
  display: block; width: 24px; height: 24px; border-radius: 50%;
  background: #8a7f6d; margin: 2px; transition: transform .18s, background .18s;
}
.switch input:checked + .switch-track { background: #5c4c1c; border-color: var(--gold); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); background: var(--gold); }

/* ---------- fee list ---------- */
.fee-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 14px 15px; margin-bottom: 9px;
}
.fee-item:disabled { opacity: .45; }
.fee-item .amt { font-family: Georgia, serif; font-size: 17px; color: var(--gold-soft); flex: none; }
.fee-item .ext { font-size: 12px; color: var(--muted-solid); margin-top: 3px; }

/* ---------- payment method toggle ---------- */
.method-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.method-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted-solid);
  border-radius: 11px; padding: 14px 8px; font-size: 13.5px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.method-btn.selected { border-color: var(--gold); background: #2e2712; color: var(--gold-soft); }
.method-icon { font-size: 21px; line-height: 1; }
.tap-explain {
  font-size: 13px; color: var(--muted-solid); line-height: 1.6;
  background: var(--panel-2); border: 1px dashed var(--line);
  border-radius: 9px; padding: 12px 14px;
}

/* ---------- contactless overlay ---------- */
.tap-sheet {
  position: fixed; inset: 0; background: #0b0a08f2; z-index: 60;
  display: none; place-items: center; padding: 22px;
}
.tap-sheet.open { display: grid; }
.tap-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 22px 22px; text-align: center; width: 100%; max-width: 380px;
}
.tap-amount { font-family: Georgia, serif; font-size: 34px; margin-top: 8px; color: var(--gold-soft); }
.tap-title { font-size: 17px; margin-top: 12px; line-height: 1.35; }
.tap-sub { font-size: 13.5px; color: var(--muted-solid); margin-top: 8px; line-height: 1.5; }

.nfc { position: relative; width: 108px; height: 108px; margin: 0 auto; }
.nfc-dot {
  position: absolute; top: 50%; left: 50%; width: 15px; height: 15px;
  margin: -7.5px 0 0 -7.5px; border-radius: 50%; background: var(--gold);
}
.nfc-wave {
  position: absolute; top: 50%; left: 50%; border-radius: 50%;
  border: 2px solid var(--gold); opacity: 0;
  animation: nfcPulse 2.1s ease-out infinite;
}
.nfc-wave.w1 { width: 44px;  height: 44px;  margin: -22px 0 0 -22px; animation-delay: 0s; }
.nfc-wave.w2 { width: 74px;  height: 74px;  margin: -37px 0 0 -37px; animation-delay: .35s; }
.nfc-wave.w3 { width: 104px; height: 104px; margin: -52px 0 0 -52px; animation-delay: .7s; }
@keyframes nfcPulse {
  0%   { opacity: 0;   transform: scale(.65); }
  35%  { opacity: .85; }
  100% { opacity: 0;   transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .nfc-wave { animation: none; opacity: .5; }
}

/* ---------- meeting list rows ---------- */
.meeting-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.meeting-row:last-child { border-bottom: none; }
.meeting-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 5px;
}
.meeting-head .list-title { line-height: 1.25; }
.meeting-head .pill { flex: none; margin-top: 1px; }
.meeting-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 11px;
}

/* ---------- camera card scan ---------- */
.scan-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-bottom: 10px;
}
.scan-icon { font-size: 18px; line-height: 1; color: var(--gold); }
.scan-tip {
  font-size: 12.5px; color: var(--muted-solid); line-height: 1.55;
  margin: 0 0 13px; text-transform: none; letter-spacing: 0;
}
.scan-tip strong { color: var(--gold-soft); }

/* ================= admin dashboard ================= */
.app.wide { max-width: 1000px; }

.tabs-scroll { overflow-x: auto; margin-bottom: 18px; -webkit-overflow-scrolling: touch; }
.tabs-scroll::-webkit-scrollbar { display: none; }
.tabs { display: flex; gap: 8px; min-width: max-content; }
.tab {
  padding: 11px 16px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--muted-solid); border-radius: 11px; font-size: 14px; white-space: nowrap;
}
.tab.active { border-color: var(--gold); color: var(--gold-soft); background: #2e2712; }

/* headline figures */
.kpi-grid {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.kpi {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 17px;
}
.kpi-label {
  font-size: 11px; color: var(--muted-solid);
  text-transform: uppercase; letter-spacing: 1.1px;
}
.kpi-value {
  font-family: Georgia, serif; font-size: 29px; margin-top: 7px; line-height: 1.1;
}
.kpi-value.gold { color: var(--gold-soft); }
.kpi-value.green { color: #8fce9c; }
.kpi-value.red { color: #f0b6ae; }
.kpi-note { font-size: 12.5px; color: var(--muted-solid); margin-top: 7px; line-height: 1.45; }

.recon {
  /* plain block so the sentence wraps normally instead of splitting into columns */
  display: block; line-height: 1.6;
  font-size: 13.5px; padding: 12px 14px; border-radius: 10px; margin-bottom: 18px;
  background: #16281a; border: 1px solid #2f5c38; color: #8fce9c;
}
.recon.bad { background: #2c1512; border-color: #6b2c24; color: #f0b6ae; }

/* chart */
.chart {
  display: flex; align-items: flex-end; gap: 4px;
  height: 170px; padding: 12px 2px 0; overflow-x: auto;
}
.chart-col {
  flex: 1 0 34px; display: flex; flex-direction: column;
  align-items: center; gap: 5px; height: 100%;
}
.chart-bars {
  flex: 1; width: 100%; display: flex; align-items: flex-end;
  justify-content: center; gap: 3px;
}
.bar { width: 13px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar.in  { background: var(--gold); }
.bar.out { background: #8a7c64; }
.chart-label {
  font-size: 10px; color: var(--muted-solid); white-space: nowrap;
  transform: rotate(-45deg); transform-origin: center; height: 22px;
}
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted-solid); margin-top: 14px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 380px; }
table.data th {
  text-align: left; font-size: 11px; color: var(--muted-solid);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 400;
  padding: 0 10px 9px 0; border-bottom: 1px solid var(--line);
}
table.data td { padding: 12px 10px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-family: Georgia, serif; white-space: nowrap; }
table.data .num.in { color: #8fce9c; }
table.data .num.out { color: #d9a08a; }

/* activity feed */
.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 8px 13px; border-radius: 999px; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted-solid);
}
.chip.active { border-color: var(--gold); color: var(--gold-soft); background: #2e2712; }

.event { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: none; }
.event-icon {
  width: 33px; height: 33px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.event-icon.in  { color: #8fce9c; border-color: #2f5c38; }
.event-icon.out { color: #d9a08a; border-color: #5a2c26; }
.event-icon.who { color: var(--gold-soft); border-color: #5c4c1c; }
.event-body { flex: 1; min-width: 0; }
.event-top { display: flex; justify-content: space-between; gap: 10px; }
.event-title { font-size: 15px; }
.event-amt { font-family: Georgia, serif; flex: none; }
.event-amt.in { color: #8fce9c; }
.event-amt.out { color: #d9a08a; }
.event-meta { font-size: 12.5px; color: var(--muted-solid); margin-top: 3px; line-height: 1.45; }

/* product editor */
.product-form {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.inline-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.retired { opacity: .55; }
