:root {
  --bg:        var(--tg-theme-bg-color, #0f1216);
  --sec:       var(--tg-theme-secondary-bg-color, #171b21);
  --card:      var(--tg-theme-section-bg-color, #1b2026);
  --text:      var(--tg-theme-text-color, #f3f5f8);
  --hint:      var(--tg-theme-hint-color, #8b95a3);
  --link:      var(--tg-theme-link-color, #5aa6ff);
  --btn:       var(--tg-theme-button-color, #3f8cff);
  --btn-text:  var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(255,255,255,.07);
  --line-strong: rgba(255,255,255,.12);
  --accent: #3f8cff;
  --accent2: #7b5cff;
  --ok: #39c06a;
  --warn: #ffb020;
  --r: 16px;
  --r-sm: 11px;
  --shadow: 0 6px 24px rgba(0,0,0,.28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px; line-height: 1.4; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
body[dir="rtl"] { direction: rtl; }
::-webkit-scrollbar { width: 0; }

/* ---------- header ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: color-mix(in srgb, var(--sec) 92%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.status { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(63,140,255,.35);
}
.who { min-width: 0; }
.who .nm { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .sb { font-size: 12.5px; color: var(--hint); margin-top: 1px; display: flex; align-items: center; gap: 6px; }
.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: rgba(63,140,255,.16); color: var(--link);
}
.badge.pro { background: linear-gradient(135deg, rgba(123,92,255,.22), rgba(63,140,255,.22)); color: #b9a6ff; }

.icon-btn {
  background: transparent; border: none; color: var(--text);
  width: 38px; height: 38px; font-size: 19px; cursor: pointer; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:active { background: rgba(255,255,255,.08); }
body[dir="rtl"] #backBtn { transform: scaleX(-1); }

main { padding: 16px 14px 48px; max-width: 680px; margin: 0 auto; }

/* ---------- headings ---------- */
h2.title { font-size: 20px; font-weight: 700; margin: 2px 2px 16px; letter-spacing: -.2px; }
.greet { font-size: 22px; font-weight: 750; margin: 4px 2px 2px; letter-spacing: -.3px; }
.greet .wave { font-weight: 400; }
.subtle { color: var(--hint); font-size: 13.5px; margin: 0 2px 16px; }
.grouphdr { color: var(--hint); font-size: 12px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; margin: 20px 4px 8px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--r); padding: 15px;
  margin-bottom: 11px; display: flex; align-items: center; gap: 14px;
  cursor: pointer; border: 1px solid var(--line);
  transition: transform .07s ease, border-color .15s ease;
}
.card:active { transform: scale(.98); border-color: var(--line-strong); }
.card.disabled { opacity: .4; pointer-events: none; }
.tile {
  width: 46px; height: 46px; flex: none; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; font-size: 23px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
}
.tile.g1 { background: linear-gradient(135deg, rgba(57,192,106,.18), rgba(57,192,106,.05)); }
.tile.g2 { background: linear-gradient(135deg, rgba(63,140,255,.20), rgba(63,140,255,.05)); }
.tile.g3 { background: linear-gradient(135deg, rgba(123,92,255,.20), rgba(123,92,255,.05)); }
.tile.g4 { background: linear-gradient(135deg, rgba(255,176,32,.20), rgba(255,176,32,.05)); }
.card .ct { flex: 1; min-width: 0; }
.card .ct .t { font-weight: 640; font-size: 15.5px; }
.card .ct .d { color: var(--hint); font-size: 13px; margin-top: 3px; }
.card .chev { color: var(--hint); font-size: 22px; opacity: .6; }
body[dir="rtl"] .card .chev { transform: scaleX(-1); }

/* store hero card */
.hero {
  position: relative; overflow: hidden; border: none; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 10px 30px rgba(63,140,255,.35);
}
.hero .ct .d { color: rgba(255,255,255,.85); }
.hero .tile { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.25); }
.hero .chev { color: rgba(255,255,255,.8); opacity: 1; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; margin-top: 12px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border-radius: var(--r); font-size: 16px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(63,140,255,.3);
}
.btn:active { transform: translateY(1px); opacity: .92; }
.btn.secondary {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line-strong); box-shadow: none;
}

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--hint); margin: 0 3px 7px; }
.field input {
  width: 100%; padding: 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--sec); color: var(--text);
  font-size: 16px; transition: border-color .15s ease;
}
.field input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63,140,255,.15); }

/* ---------- results ---------- */
.result {
  background: var(--card); border-radius: var(--r-sm); padding: 13px 14px;
  margin-bottom: 9px; cursor: pointer; display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); transition: transform .07s ease;
}
.result:active { transform: scale(.985); }
.result .ri {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--hint); font-size: 15px;
}
.result .rl { flex: 1; min-width: 0; font-size: 15px; }
.result .chev { color: var(--hint); opacity: .55; }
body[dir="rtl"] .result .chev { transform: scaleX(-1); }

.pager { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }
.pager button {
  background: var(--card); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 11px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.pager button[disabled] { opacity: .3; }

/* ---------- profile ---------- */
.phead { display: flex; align-items: center; gap: 14px; margin: 4px 2px 18px; }
.phead .pa {
  width: 54px; height: 54px; flex: none; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700;
}
.phead .pn { font-size: 20px; font-weight: 750; letter-spacing: -.2px; }

.section { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 4px 15px; margin-bottom: 12px; }
.section h3 { font-size: 11.5px; color: var(--hint); font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; margin: 13px 0 4px; }
.row { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0;
  border-bottom: 1px solid var(--line); font-size: 15px; }
.row:last-child { border-bottom: none; }
.row .k { color: var(--hint); flex: none; }
.row .v { text-align: end; word-break: break-word; font-weight: 500; }

.rels { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.rel-btn {
  padding: 10px 14px; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 999px; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--text);
}
.rel-btn:active { background: rgba(255,255,255,.06); }

/* ---------- store plans ---------- */
.plan { align-items: center; }
.plan .price {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px;
  font-weight: 700; font-size: 13.5px; color: var(--link);
}
.plan .per { color: var(--hint); font-weight: 500; }
.ribbon {
  position: absolute; inset-inline-end: -1px; top: 10px;
  background: var(--warn); color: #000; font-size: 10px; font-weight: 800;
  padding: 3px 10px; border-radius: 999px 0 0 999px; letter-spacing: .4px;
}

/* ---------- misc ---------- */
.muted { color: var(--hint); font-size: 14.5px; line-height: 1.6; white-space: pre-line; }
.notice { background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; color: var(--hint); font-size: 14.5px; line-height: 1.6; white-space: pre-line; }
.center { text-align: center; padding: 48px 20px; color: var(--hint); }
.center .big { font-size: 40px; margin-bottom: 10px; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
  margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #000; color: #fff; padding: 12px 20px; border-radius: 13px;
  font-size: 14px; max-width: 86%; text-align: center; z-index: 60;
  box-shadow: var(--shadow); animation: pop .2s ease;
}
@keyframes pop { from { transform: translate(-50%, 8px); opacity: 0; } }
