:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111114);
  --hint: var(--tg-theme-hint-color, #7b7f8a);
  --accent: var(--tg-theme-button-color, #1f8f5f);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --sec: var(--tg-theme-secondary-bg-color, #f1f2f5);
  --line: rgba(127, 127, 140, .22);
  --good: #1a9a55;
  --bad: #d64545;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 100vh; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px 4px; }
.title { font-weight: 700; font-size: 18px; }
main { padding: 8px 16px 16px; max-width: 560px; margin: 0 auto; }
[hidden] { display: none !important; }

.seg { display: inline-flex; background: var(--sec); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--hint); font: inherit; font-size: 13px;
  font-weight: 600; padding: 5px 10px; border-radius: 8px; }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.card { background: linear-gradient(135deg, #17805a, #2bb673 60%, #6fd6a0); color: #fff;
  border-radius: 20px; padding: 20px; box-shadow: 0 8px 24px rgba(23, 128, 90, .28); }
.card .lbl { opacity: .85; font-size: 13px; }
.card .bal { font-size: 36px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 14px; }
.card .row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.card .row b { font-weight: 600; }
.card .who { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.3);
  font-size: 14px; opacity: .95; display: flex; justify-content: space-between; gap: 8px; }

h2 { font-size: 15px; margin: 22px 0 8px; color: var(--hint); font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; }
.box { background: var(--sec); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.list { background: var(--sec); border-radius: var(--r); overflow: hidden; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item.tap { cursor: pointer; }
.item.tap:active { background: var(--line); }
.item .main { min-width: 0; flex: 1; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .s { color: var(--hint); font-size: 13px; overflow-wrap: anywhere; }
.item .amt { font-weight: 700; white-space: nowrap; text-align: right; }
.amt.plus { color: var(--good); }
.amt.minus { color: var(--bad); }
.item.dead .t, .item.dead .amt { text-decoration: line-through; opacity: .55; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: var(--line); color: var(--hint); margin-left: 6px; vertical-align: 1px; }
.tag.good { background: rgba(26,154,85,.16); color: var(--good); }

label { display: block; font-size: 13px; color: var(--hint); margin: 10px 0 4px; }
input[type=text], input[type=search], input[type=tel], input[type=number] {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; }
input:focus { border-color: var(--accent); }
.big { font-size: 24px !important; font-weight: 700; }
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px; margin-top: 12px;
  font: inherit; font-weight: 700; background: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .45; }
.btn.ghost { background: var(--bg); color: var(--accent); border: 1.5px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { display: inline-block; width: auto; padding: 7px 12px; margin: 0; font-size: 14px; }
.row2 { display: flex; gap: 8px; align-items: center; }
.row2 > input { flex: 1; }
.preview { margin-top: 10px; font-size: 15px; color: var(--hint); min-height: 22px; }
.preview b { color: var(--good); font-size: 18px; }
.link { color: var(--accent); font-weight: 600; background: none; border: 0; font: inherit;
  font-weight: 600; padding: 4px 0; }
.empty { color: var(--hint); text-align: center; padding: 28px 12px; }
.back { margin: 4px 0 8px; }
.cust-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.cust-head .bal { font-size: 26px; font-weight: 800; color: var(--good); white-space: nowrap; }
.err { color: var(--bad); font-size: 14px; margin-top: 8px; }

nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 4px; }
nav button { flex: 1; border: 0; background: none; color: var(--hint); font: inherit; font-size: 12px;
  font-weight: 600; padding: 6px 2px; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; }
nav button .ic { font-size: 20px; line-height: 1; }
nav button.on { color: var(--accent); background: var(--sec); }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto; background: #20222a; color: #fff; padding: 12px 14px;
  border-radius: 12px; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 10; }
#toast.bad { background: var(--bad); }
.center { text-align: center; padding: 40px 8px; }
.center .big-ic { font-size: 56px; }

.mt0 { margin-top: 0 !important; }
.mt8 { margin-top: 8px !important; }
.mt10 { margin-top: 10px !important; }
.mt12 { margin-top: 12px !important; }
.name18 { font-weight: 700; font-size: 18px; }
.hint { color: var(--hint); }
.small13 { font-size: 13px; }

.row2 > input { min-width: 0; }
.row2 > .btn { flex: none; }

/* Sale preview, touch-friendly redemption control */
.sale-redeem-header { display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-top:10px; }
.sale-redeem-header label { margin:0; }
.amount-strong { font-size:18px; font-weight:700; color:var(--good); }
input[type=range] { display:block; width:100%; margin:14px 0 8px; accent-color:var(--accent); min-height:28px; }
.sale-controls { justify-content:flex-end; flex-wrap:wrap; }
.sale-summary { border-top:1px solid var(--line); padding-top:9px; margin-top:13px; }
.sale-summary-row { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 0; font-size:14px; }
.sale-summary-row b { font-variant-numeric:tabular-nums; text-align:right; white-space:nowrap; }
.pct-setting + .pct-setting { border-top:1px solid var(--line); padding-top:12px; margin-top:12px; }

/* Three-dot actions: only the super-admin receives destructive options. */
.list { overflow: visible; }
.item { position: relative; }
.op-actions { display:flex; align-items:center; flex-direction:column; gap:6px; }
.op-menu { position:relative; align-self:flex-end; }
.op-menu-trigger { display:flex; align-items:center; justify-content:center; width:36px; height:36px;
  border-radius:10px; cursor:pointer; font-size:25px; font-weight:700; color:var(--text); list-style:none; }
.op-menu-trigger::-webkit-details-marker { display:none; }
.op-menu-trigger:active { background:var(--line); }
.op-menu-pop { position:absolute; right:0; bottom:100%; z-index:6; min-width:190px;
  background:var(--bg); border:1px solid var(--line); border-radius:12px;
  box-shadow:0 8px 28px rgba(0,0,0,.18); padding:5px; }
.op-menu-danger { width:100%; text-align:left; background:none; border:0; border-radius:8px;
  padding:12px; font:inherit; font-size:14px; font-weight:600; color:var(--bad); cursor:pointer; }
.op-menu-danger:active { background:var(--sec); }
.cancel-backdrop { position:fixed; inset:0; z-index:30; background:rgba(0,0,0,.58);
  display:flex; justify-content:center; align-items:center; padding:16px; }
.cancel-dialog { width:min(100%,440px); max-height:90dvh; overflow-y:auto;
  background:var(--bg); color:var(--text); border-radius:18px; padding:18px;
  box-shadow:0 14px 50px rgba(0,0,0,.25); }
.cancel-dialog h3 { margin:0 0 12px; font-size:19px; }
.cancel-dialog p { margin:9px 0; }
.cancel-dialog-actions { display:flex; gap:9px; margin-top:16px; }
.cancel-dialog-actions > .btn { flex:1; min-width:0; margin:0; font-size:14px; }

.role-note { display:inline-block; margin:0 0 10px; color:var(--hint); font-size:12px; font-weight:650; }
