/* ═══════════════════════════════════════════════════════════
   Bot Admin — Telegram Mini App
   "Skorio"-inspired dark theme: near-black surfaces, neon-mint
   accent, big rounded cards, pill chips, floating tab bar.
   Committed dark brand look (independent of Telegram theme).
   ═══════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg:        #000000;
  --surface:   #141414;
  --surface-2: #1d1d1d;
  --elevate:   #262626;

  /* text */
  --text:   #ffffff;
  --hint:   #a6a6a6;
  --muted:  #6f6f6f;

  /* brand */
  --accent:      #ff7a1a;   /* orange */
  --accent-dim:  #d1620f;
  --accent-ink:  #ffffff;   /* white text on the orange button */
  --accent-8:    rgba(255,122,26,.10);
  --accent-16:   rgba(255,122,26,.18);
  --accent-glow: rgba(255,122,26,.40);

  /* status */
  --ok:   #35d07a;
  --warn: #e7b13c;
  --err:  #ff5d5d;
  --ok-bg:   rgba(53,208,122,.16);
  --warn-bg: rgba(231,177,60,.16);
  --err-bg:  rgba(255,93,93,.15);

  /* lines / press */
  --sep:      rgba(255,255,255,.08);
  --sep-soft: rgba(255,255,255,.05);
  --press:    rgba(255,255,255,.06);
  --shadow:   0 2px 6px rgba(0,0,0,.35), 0 14px 40px rgba(0,0,0,.28);

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --r-pill: 999px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* faint stadium-style glow */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255,122,26,.12), transparent 60%),
    radial-gradient(90% 50% at 50% 110%, rgba(255,122,26,.06), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .85; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ══════════ GATE / BLOCKED ══════════ */
.gate, .blocked {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 32px; background: var(--bg); z-index: 50;
}
.gate-box { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--sep);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  box-shadow: 0 0 22px var(--accent-glow);
}
@keyframes spin { to { transform: rotate(360deg); } }
.gate-text { margin: 0; color: var(--hint); font-size: 15px; }
.gate.is-error .spinner { display: none; }
.gate-err-icon { width: 46px; height: 46px; color: var(--err); }
.gate-retry {
  margin-top: 4px; padding: 11px 24px;
  border: none; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-ink);
  font-size: 15px; font-weight: 700;
}

.blocked-inner { max-width: 340px; text-align: center; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 1; }
.blocked-icon {
  width: 76px; height: 76px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 24px; background: var(--err-bg); color: var(--err);
  margin-bottom: 22px;
}
.blocked-icon svg { width: 36px; height: 36px; }
.blocked-title { margin: 0 0 8px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.blocked-desc { margin: 0 0 24px; color: var(--hint); font-size: 15px; }
.blocked-id {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 22px; background: var(--surface);
  border: 1px solid var(--sep); border-radius: var(--r-md);
  font-size: 13px; color: var(--hint);
}
.blocked-id b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ══════════ APP SHELL ══════════ */
.app { display: flex; flex-direction: column; height: 100dvh; height: 100vh; position: relative; z-index: 1; }

.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  height: calc(56px + env(safe-area-inset-top));
  background: linear-gradient(var(--bg), color-mix(in srgb, var(--bg) 70%, transparent));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--sep-soft);
}
.topbar-title {
  flex: 1; min-width: 0; text-align: center;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.iconbtn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--sep); background: var(--surface);
  color: var(--accent); border-radius: 50%;
  transition: background .15s, transform .1s;
  flex: 0 0 auto;
}
.iconbtn:active { background: var(--press); transform: scale(.94); }
.iconbtn svg { width: 22px; height: 22px; }
.topbar-back { border: none; background: transparent; }
.iconbtn.spinning svg { animation: spin .7s linear infinite; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-16); color: var(--accent);
  font-size: 13px; font-weight: 700; flex: 0 0 auto;
  border: 1px solid var(--accent-16);
}

.main {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(104px + env(safe-area-inset-bottom));
}

/* ══════════ SCREENS ══════════ */
.screen { display: block; }
.screen[hidden] { display: none; }
.screen.enter { animation: screenIn .28s cubic-bezier(.22,.61,.36,1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Home hero → "profile" style header */
.hero {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 6px 22px;
}
.hero-avatar {
  width: 62px; height: 62px; border-radius: 20px; font-size: 22px;
  background: radial-gradient(120% 120% at 30% 20%, var(--accent-16), var(--surface));
  border: 1px solid var(--accent-16);
  box-shadow: 0 0 30px var(--accent-8);
}
.hero-text { min-width: 0; }
.hero-name { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.hero-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px 4px 8px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 800; letter-spacing: .01em;
  background: var(--accent-16); color: var(--accent);
}
.badge svg { width: 13px; height: 13px; }
.hero-uid { font-size: 13px; color: var(--hint); font-variant-numeric: tabular-nums; }

.section-label {
  display: block;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 6px 4px 12px;
}

/* Tool grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  text-align: left; padding: 16px 15px 17px;
  border: 1px solid var(--sep); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .15s, background .15s;
  min-height: 132px;
}
.card:active { transform: scale(.975); background: var(--elevate); }
.card-ic {
  width: 44px; height: 44px; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px; color: var(--accent);
  background: var(--accent-8); border: 1px solid var(--accent-16);
}
.card-ic svg { width: 24px; height: 24px; }
.ic-blue   { color: #4ea6ff; background: rgba(78,166,255,.10); border-color: rgba(78,166,255,.20); }
.ic-teal   { color: #2fe8c6; background: rgba(47,232,198,.10); border-color: rgba(47,232,198,.20); }
.ic-violet { color: #b18bff; background: rgba(177,139,255,.12); border-color: rgba(177,139,255,.22); }
.ic-amber  { color: #f0c24a; background: rgba(240,194,74,.12); border-color: rgba(240,194,74,.22); }
.ic-green  { color: var(--accent); background: var(--accent-8); border-color: var(--accent-16); }
.ic-slate  { color: #9fb0aa; background: rgba(159,176,170,.10); border-color: rgba(159,176,170,.20); }
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { font-size: 12.5px; color: var(--hint); }
.count-chip {
  min-width: 22px; padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--accent-16); color: var(--accent);
  font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; justify-content: center;
}
.card .count-chip { position: absolute; top: 14px; right: 14px; }

/* Stat block (broadcast) */
.stat {
  display: flex; align-items: baseline; gap: 12px;
  padding: 18px 18px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.stat-num { font-size: 34px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; }
.stat-label { font-size: 13px; color: var(--hint); }

/* ══════════ FORMS ══════════ */
.field { margin-bottom: 4px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--hint); margin: 14px 2px 7px; }
.opt { color: var(--muted); font-weight: 400; }

.input, textarea.input, select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--sep);
  border-radius: var(--r-md);
  padding: 13px 14px;
  font-size: 15px; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.input::placeholder, textarea.input::placeholder { color: var(--muted); }
.input:focus, textarea.input:focus, select:focus {
  outline: none; border-color: var(--accent); background: #0d0d0d;
  box-shadow: 0 0 0 3px var(--accent-8);
}
.textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.field-hint { font-size: 12px; color: var(--muted); margin: 7px 2px 0; }
.row-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-field .field-label { margin: 0; }

/* ══════════ BUTTONS ══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 16px;
  padding: 15px 18px;
  border: none; border-radius: var(--r-md);
  font-size: 15px; font-weight: 800; letter-spacing: -.01em;
  transition: transform .1s ease, opacity .15s, filter .15s;
}
.btn svg { width: 19px; height: 19px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 26px rgba(255,122,26,.28); }
.btn-primary:disabled { box-shadow: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--sep); }
.btn-destructive { background: var(--err); color: #fff; }
.btn-warn { background: var(--warn); color: #1a1305; }
.btn-sm { width: auto; margin: 0; padding: 10px 18px; font-size: 14px; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { margin-top: 16px; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 2.5px solid rgba(0,0,0,.25); border-top-color: currentColor;
  border-radius: 50%; animation: spin .7s linear infinite; color: var(--accent-ink);
}
.btn-secondary.is-loading::after, .btn-warn.is-loading::after { color: var(--text); }

.panel {
  padding: 16px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-lg);
}
.panel .btn { margin-top: 12px; }

/* ══════════ GROUP LIST ══════════ */
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 8px; }
.list-head .section-label { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.list { display: flex; flex-direction: column; gap: 9px; }
.group-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.group-row:active { background: var(--elevate); }
.gchk { position: absolute; opacity: 0; width: 0; height: 0; }
.gcheck {
  width: 22px; height: 22px; flex: 0 0 auto;
  border: 2px solid var(--muted); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.gchk:checked + .gcheck { background: var(--accent); border-color: var(--accent); }
.gchk:checked + .gcheck::after {
  content: ""; width: 6px; height: 11px;
  border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translateY(-1px);
}
.ginfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gtitle { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmeta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; line-height: 1.6; }

.bulkbar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding: 12px 14px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--sep); border-radius: var(--r-md);
}
.bulkbar-info { font-size: 14px; color: var(--hint); }
.bulkbar-info b { color: var(--text); }

/* ══════════ STEPPER ══════════ */
.stepper {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--sep); border-radius: var(--r-pill);
  padding: 4px;
}
.stepper-btn {
  width: 34px; height: 34px; border: none; border-radius: 50%;
  background: transparent; color: var(--accent);
  font-size: 20px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.stepper-btn:active { background: var(--press); }
.stepper-btn:disabled { color: var(--muted); }
.stepper-val { min-width: 26px; text-align: center; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ══════════ PROMOTE TARGET / SETTINGS ══════════ */
.target-card {
  display: flex; align-items: center; gap: 13px;
  padding: 15px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-lg);
}
.target-avatar {
  width: 46px; height: 46px; border-radius: 14px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-16); color: var(--accent); font-weight: 800; font-size: 17px;
}
.target-text { flex: 1; min-width: 0; }
.target-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.target-value { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { border: none; background: transparent; color: var(--accent); font-size: 14px; font-weight: 700; padding: 6px; }

.current-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-md);
}
.current-label { font-size: 13px; color: var(--hint); }
.current-value { font-size: 15px; font-weight: 700; color: var(--accent); }

/* ══════════ IMAGE PICKER (Photo Post) ══════════ */
.filepick {
  display: block; overflow: hidden; cursor: pointer;
  border: 1.5px dashed var(--sep); border-radius: var(--r-md); background: var(--surface-2);
  transition: border-color .15s;
}
.filepick:active { border-color: var(--accent); }
.filepick-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 30px 16px; color: var(--muted); font-size: 14px;
}
.filepick-empty svg { width: 30px; height: 30px; }
.filepick-preview { display: block; width: 100%; max-height: 260px; object-fit: cover; }

/* ══════════ RESULTS ══════════ */
.result { margin-top: 16px; }
.result-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 700;
}
.result-summary svg { width: 20px; height: 20px; flex: 0 0 auto; }
.result-summary.ok    { background: var(--ok-bg);   color: var(--ok); }
.result-summary.err   { background: var(--err-bg);  color: var(--err); }
.result-summary.mixed { background: var(--warn-bg); color: var(--warn); }

.counts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cpill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--sep); color: var(--hint);
}
.cpill b { font-variant-numeric: tabular-nums; }
.cpill.ok   { color: var(--ok);   border-color: var(--ok-bg); }
.cpill.warn { color: var(--warn); border-color: var(--warn-bg); }
.cpill.err  { color: var(--err);  border-color: var(--err-bg); }

.rlist { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.rline {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-md);
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(53,208,122,.5); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }
.rline-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rline-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rline-detail { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtag {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  padding: 4px 9px; border-radius: var(--r-pill); flex: 0 0 auto;
  background: var(--surface-2); color: var(--hint);
}
.rtag.ok { background: var(--ok-bg); color: var(--ok); }
.rtag.warn { background: var(--warn-bg); color: var(--warn); }
.rtag.err { background: var(--err-bg); color: var(--err); }

hr { border: none; border-top: 1px solid var(--sep); margin: 22px 0; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 12px; color: var(--accent); }

/* ══════════ BOTTOM TAB BAR ══════════ */
.tabbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 4px;
  padding: 7px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--sep); border-radius: 24px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.tabitem {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 7px; border: none; background: transparent;
  color: var(--muted); border-radius: 18px;
  font-size: 11px; font-weight: 700;
  transition: background .18s, color .18s;
}
.tabitem svg { width: 22px; height: 22px; }
.tabitem.active { background: var(--accent-16); color: var(--accent); }

/* ══════════ TOAST ══════════ */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  max-width: calc(100% - 40px);
  padding: 12px 20px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 700;
  box-shadow: 0 10px 34px rgba(255,122,26,.3);
  opacity: 0; transition: opacity .25s, transform .25s;
  z-index: 60; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════ DEMO THEME TOGGLE (only injected outside Telegram) ══════════ */
.demo-toggle {
  position: fixed; right: 14px; bottom: calc(92px + env(safe-area-inset-bottom));
  display: flex; gap: 2px; padding: 3px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--sep); border-radius: var(--r-pill);
  z-index: 70; box-shadow: var(--shadow);
}
.demo-toggle button {
  border: none; background: transparent; color: var(--muted);
  font-size: 11px; font-weight: 800; padding: 5px 11px; border-radius: var(--r-pill);
}
.demo-toggle button.on { background: var(--accent); color: var(--accent-ink); }
