:root {
  --bg: var(--tg-theme-bg-color, #0f1117);
  --bg2: var(--tg-theme-secondary-bg-color, #171a23);
  --text: var(--tg-theme-text-color, #e9ecf2);
  --hint: var(--tg-theme-hint-color, #8b93a7);
  --link: var(--tg-theme-link-color, #6ea8fe);
  --btn: var(--tg-theme-button-color, #3b82f6);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.7; -webkit-font-smoothing: antialiased;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: 84px; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg); border-bottom: 1px solid color-mix(in srgb, var(--hint) 18%, transparent);
}
.brand { font-weight: 800; font-size: 17px; }
.balance { font-size: 13px; color: var(--hint); }
main { padding: 14px 16px; }
.loading, .empty { text-align: center; color: var(--hint); padding: 40px 0; }
.card {
  background: var(--bg2); border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 16px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--hint); font-size: 13px; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.b-active { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.b-suspended { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.b-failed { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.b-provisioning { background: color-mix(in srgb, var(--btn) 20%, transparent); color: var(--btn); }
.list-item { cursor: pointer; }
.list-item:active { opacity: .8; }
label { display: block; font-size: 13px; color: var(--hint); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--hint) 30%, transparent);
  background: var(--bg); color: var(--text); font: inherit; direction: ltr; text-align: left;
}
textarea { min-height: 90px; direction: rtl; text-align: right; }
input.rtl { direction: rtl; text-align: right; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 11px 14px; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--btn); color: var(--btn-text); text-decoration: none;
}
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--link); border: 1px solid color-mix(in srgb, var(--link) 40%, transparent); }
button.danger { background: var(--danger); color: #fff; }
button.block { width: 100%; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.plans { display: grid; gap: 8px; margin-top: 6px; }
.plan {
  border: 2px solid transparent; background: var(--bg); border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.plan.sel { border-color: var(--btn); }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress > i { display: block; height: 100%; background: var(--btn); width: 0; transition: width .4s; }
.log { font-size: 12px; direction: rtl; background: var(--bg); border-radius: 10px; padding: 8px 10px; max-height: 260px; overflow: auto; white-space: pre-wrap; }
.log .error { color: var(--danger); }
.log .warn { color: var(--warn); }
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 4px;
  background: var(--bg2); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs a {
  flex: 1; max-width: 150px; text-align: center; font-size: 12px; color: var(--hint); text-decoration: none;
  padding: 4px 0; border-radius: 10px; display: flex; flex-direction: column;
}
.tabs a span { font-size: 19px; line-height: 1.3; }
.tabs a.on { color: var(--btn); background: color-mix(in srgb, var(--btn) 12%, transparent); }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: #000c; color: #fff;
  padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 20; max-width: 90%; text-align: center;
}
.subtabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.subtabs button { padding: 7px 12px; font-size: 13px; background: var(--bg2); color: var(--text); white-space: nowrap; }
.subtabs button.on { background: var(--btn); color: var(--btn-text); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv b { color: var(--hint); font-weight: 400; }
.ltr { direction: ltr; unicode-bidi: embed; }
.stat { text-align: center; }
.stat b { display: block; font-size: 20px; }
.back { background: transparent; color: var(--link); padding: 0; margin-bottom: 10px; font-weight: 400; }
hr { border: 0; border-top: 1px solid color-mix(in srgb, var(--hint) 18%, transparent); margin: 12px 0; }
