/* ══════════════════════════════════════════════════════════════════════════════
   TeleShort UI — hand-rolled tokens + components.
   Replaces the Tailwind Play CDN + Font Awesome CDN of 1.x: those compiled CSS in
   the browser on every load, added two render-blocking third-party round trips, and
   are explicitly "not for production" per Tailwind's own docs.
   ══════════════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-2: #0b1120;
  --panel: rgba(30, 41, 59, 0.75);
  --panel-solid: #1e293b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(148, 163, 184, 0.22);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --brand: #6366f1;
  --brand-2: #3b82f6;
  --brand-soft: rgba(99, 102, 241, 0.16);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --bad: #f87171;
  --bad-soft: rgba(239, 68, 68, 0.14);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --tap: 44px; /* WCAG 2.5.5 target size */
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 62px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 520px at 50% -12%, rgba(79, 70, 229, 0.24), transparent 62%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  font-family:
    'Inter Variable',
    Inter,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Noto Sans Bengali',
    'Hind Siliguri',
    sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
p {
  color: var(--muted);
  font-size: 13.5px;
}
code,
.mono {
  font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, monospace;
}
a {
  color: #93c5fd;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 90;
  background: var(--panel-solid);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line-strong);
  transition: top 0.18s ease;
}
.skip-link:focus {
  top: 12px;
}

/* ── layout ─────────────────────────────────────────────────────────────────── */
.wrap {
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
  padding-inline: 16px;
}
.stack > * + * {
  margin-top: 14px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wrap-any {
  min-width: 0;
  flex: 1;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.mt-4 {
  margin-top: 4px;
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mt-24 {
  margin-top: 24px;
}
.mb-16 {
  margin-bottom: 16px;
}
.center {
  text-align: center;
}
.muted {
  color: var(--muted);
}
.tiny {
  font-size: 11.5px;
}
.small {
  font-size: 13px;
}
.strong {
  font-weight: 700;
}
.ok-text {
  color: #34d399;
}
.brand-text {
  color: #a5b4fc;
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── panels ───────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
@supports not (backdrop-filter: blur(2px)) {
  .panel {
    background: var(--panel-solid);
  }
}
.panel-accent {
  border-color: rgba(99, 102, 241, 0.28);
}
.panel-tight {
  padding: 13px 14px;
}
.hero {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(15, 23, 42, 0.1));
}

.label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ── header ───────────────────────────────────────────────────────────────────── */
.appbar {
  position: sticky;
  top: 8px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px auto 16px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}
.brand-mark svg {
  width: 19px;
  height: 19px;
}
.balance-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid var(--line-strong);
  font-weight: 800;
  font-size: 13.5px;
  color: #34d399;
}
.balance-pill svg {
  width: 15px;
  height: 15px;
}

/* ── buttons ──────────────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 0;
  border-radius: var(--r);
  background: var(--btn-bg);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.12s ease,
    filter 0.15s ease,
    opacity 0.15s ease;
}
.btn:hover {
  filter: brightness(1.07);
}
.btn:active {
  transform: scale(0.985);
}
.btn-block {
  width: 100%;
}
.btn-lg {
  min-height: 52px;
  font-size: 15.5px;
}
.btn-quiet {
  --btn-bg: rgba(148, 163, 184, 0.13);
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-ok {
  --btn-bg: linear-gradient(135deg, var(--ok), #059669);
}
.btn-danger {
  --btn-bg: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.btn-sm {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: 9px;
}
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: progress;
  filter: none;
}
.btn.is-busy::before {
  content: '';
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── forms ────────────────────────────────────────────────────────────────────── */
.field {
  width: 100%;
  min-height: var(--tap);
}
input.field,
select.field,
textarea.field {
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  font-size: 14px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
input.field:focus,
select.field:focus,
textarea.field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
  outline: none;
}
input.field::placeholder {
  color: var(--muted-2);
}
select.field {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='%2394a3b8' viewBox='0 0 24 24'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}
.field-error {
  color: var(--bad);
  font-size: 12px;
  margin-top: 6px;
  min-height: 1em;
}
.field-hint {
  color: var(--muted-2);
  font-size: 12px;
  margin-top: 6px;
}
.field-invalid {
  border-color: rgba(239, 68, 68, 0.6);
}
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

/* ── copy field (secret-safe: reveal toggle + copy) ───────────────────────────── */
.copybox {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 6px;
}
.copybox-value {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  color: #c7d2fe;
}
.copybox-value.is-secret {
  letter-spacing: 0.06em;
}

/* ── stat cards ───────────────────────────────────────────────────────────────── */
.stat {
  padding: 15px;
  text-align: center;
}
.stat-k {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.stat-v {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 3px;
}
.stat-v.big {
  font-size: 38px;
}
.cpm-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  grid-column: span 2;
  text-align: left;
}

/* ── lists / rows ─────────────────────────────────────────────────────────────── */
.list {
  display: grid;
  gap: 10px;
}
.item {
  padding: 13px 14px;
}
.item-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #a5b4fc;
}
.item-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
}
.item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--warn-soft);
  color: #fcd34d;
}
.badge-ok {
  background: var(--ok-soft);
  color: #6ee7b7;
}
.badge-bad {
  background: var(--bad-soft);
  color: #fca5a5;
}
.badge-neutral {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty svg {
  width: 26px;
  height: 26px;
  opacity: 0.5;
  display: block;
  margin: 0 auto 8px;
}

/* ── nav ──────────────────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 6px 6px calc(6px + var(--safe-b));
  background: rgba(15, 23, 42, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.nav-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 50px;
  padding: 6px 2px 4px;
  background: none;
  border: 0;
  border-radius: 12px;
  color: var(--muted-2);
  font: inherit;
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
  transition:
    color 0.18s ease,
    background 0.18s ease;
}
.nav-btn svg {
  width: 20px;
  height: 20px;
}
.nav-btn[aria-current='page'] {
  color: #93c5fd;
  background: rgba(96, 165, 250, 0.12);
}

/* ── views ────────────────────────────────────────────────────────────────────── */
.view {
  animation: rise 0.22s ease-out;
}
.view + .view {
  margin-top: 4px;
}

/* ── toasts ───────────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
  z-index: 70;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r);
  background: rgba(2, 6, 23, 0.94);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  animation: rise 0.2s ease-out;
}
.toast svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
}
.toast-ok {
  border-color: rgba(16, 185, 129, 0.5);
}
.toast-err {
  border-color: rgba(239, 68, 68, 0.55);
}
.toast-err .toast-x {
  margin-inline-start: auto;
}

/* ── banners ──────────────────────────────────────────────────────────────────── */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--bad-soft);
  border: 1px solid rgba(239, 68, 68, 0.42);
  font-size: 13px;
}
.banner-warn {
  background: var(--warn-soft);
  border-color: rgba(245, 158, 11, 0.42);
}
.banner-info {
  background: var(--brand-soft);
  border-color: rgba(99, 102, 241, 0.42);
}
.banner svg {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 1px;
}
.banner-body {
  flex: 1;
  min-width: 0;
}
.banner-title {
  font-weight: 800;
  font-size: 13.5px;
  color: var(--text);
}
.banner-text {
  color: #fecaca;
  font-size: 12.5px;
  margin-top: 3px;
}
.banner-warn .banner-text {
  color: #fde68a;
}
.banner-info .banner-text {
  color: #c7d2fe;
}

/* ── boot / blocking screen ───────────────────────────────────────────────────── */
.boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.boot-inner {
  text-align: center;
  max-width: 22rem;
}
.boot-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 40px rgba(79, 70, 229, 0.45);
  animation: pulse 1.8s ease-in-out infinite;
}
.boot-mark svg {
  width: 30px;
  height: 30px;
}
.boot h2 {
  margin-bottom: 6px;
}
.boot p {
  font-size: 13.5px;
}

/* ── ad viewer (modal) ────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(6px);
  overflow: auto;
}
.ad-card {
  width: 100%;
  max-width: 26rem;
  padding: 26px 22px;
  text-align: center;
}
.ring {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 18px;
}
.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: rgba(148, 163, 184, 0.2);
  stroke-width: 8;
}
.ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.95s linear;
}
.ring-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 27px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.step-pill {
  display: inline-block;
  margin-bottom: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #c7d2fe;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ad-note {
  font-size: 12.5px;
  color: var(--muted);
  min-height: 2.6em;
}

/* ── chart ────────────────────────────────────────────────────────────────────── */
.chart {
  width: 100%;
  height: 74px;
  display: block;
  overflow: visible;
}
.chart-line {
  fill: none;
  stroke: #818cf8;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-area {
  fill: rgba(129, 140, 248, 0.18);
  stroke: none;
}
.chart-dot {
  fill: #c7d2fe;
}
.chart-legend {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted-2);
  margin-top: 6px;
}

/* ── skeletons ────────────────────────────────────────────────────────────────── */
.sk {
  border-radius: 9px;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.09) 0%,
    rgba(148, 163, 184, 0.2) 50%,
    rgba(148, 163, 184, 0.09) 100%
  );
  background-size: 300% 100%;
  animation: shimmer 1.25s linear infinite;
  height: 15px;
}
.sk-row {
  height: 78px;
  border-radius: var(--r-lg);
}
.sk-stack > * + * {
  margin-top: 10px;
}

/* ── motion ───────────────────────────────────────────────────────────────────── */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}
@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}
@keyframes bounceSoft {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
.cta-attention {
  animation: bounceSoft 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .ring-fill {
    transition: none;
  }
}

@media (min-width: 780px) {
  body {
    font-size: 15.5px;
  }
  .grid-2 {
    gap: 14px;
  }
}
