/* ═══════════════════════════════════════════════════════════════════
   Mini App — Styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────────── */
:root {
  /* Colors */
  --color-bg-start:   #000000;
  --color-bg-mid:     #18184a;
  --color-bg-end:     #12123d;
  --color-accent:     #006eff;
  --color-accent-dark: #0050cc;
  --color-accent-light: #00b7ff;
  --color-success:    #22c55e;
  --color-warning:    #f59e0b;
  --color-danger:     #ef4444;
  --color-text:       #fff;
  --color-text-muted: rgba(255, 255, 255, .78);
  --color-text-dim:   rgba(255, 255, 255, .62);
  --color-text-faint: rgba(255, 255, 255, .52);
  --color-error:      #f87171;

  /* Surfaces */
  --surface-card:     rgba(255, 255, 255, .08);
  --surface-elevated: rgba(255, 255, 255, .10);
  --surface-hover:    rgba(255, 255, 255, .15);
  --surface-border:   rgba(255, 255, 255, .08);
  --surface-input-border: rgba(255, 255, 255, .15);
  --surface-input-focus:  rgba(255, 255, 255, .35);
  --surface-input-bg: rgba(255, 255, 255, .10);
  --surface-input-bg-focus: rgba(255, 255, 255, .13);

  /* Accent surfaces */
  --surface-accent:   rgba(0, 183, 255, .18);
  --surface-accent-border: rgba(0, 183, 255, .32);
  --surface-accent-selected: rgba(0, 183, 255, .14);
  --surface-danger-bg: rgba(239, 68, 68, .15);
  --surface-danger-bg-hover: rgba(239, 68, 68, .25);
  --surface-danger-border: rgba(239, 68, 68, .32);

  /* Gradients */
  --gradient-bg:      linear-gradient(180deg, #000000 0%, #18184a 50%, #12123d 100%);
  --gradient-primary: linear-gradient(135deg, #0050cc 0%, #0090dd 100%);
  --gradient-sheet:   linear-gradient(180deg, #14142c 0%, #0b0b16 100%);

  /* Shadows */
  --shadow-thumb:     0 2px 6px rgba(0, 0, 0, .35);
  --shadow-card:      0 10px 24px rgba(0, 0, 0, .18);

  /* Spacing */
  --space-1:          4px;
  --space-2:          8px;
  --space-3:          12px;
  --space-4:          16px;
  --space-5:          24px;
  --gap:              var(--space-2);
  --padding-screen:   24px;
  --padding-card:     16px;
  --padding-btn:      18px;

  /* Sizing */
  --btn-height:       60px;
  --btn-height-sm:    48px;
  --header-height:    var(--btn-height);
  --header-btn-size:  40px;
  --icon-box:         44px;
  --icon-box-radius:  12px;

  /* Radii */
  --radius-card:      16px;
  --radius-btn:       16px;
  --radius-sheet:     24px;
  --radius-pill:      999px;

  /* Typography */
  --font-family:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --fs-xs:            12px;
  --fs-sm:            13px;
  --fs-base:          14px;
  --fs-md:            15px;
  --fs-lg:            16px;
  --fs-xl:            17px;
  --fs-2xl:           22px;
  --fs-3xl:           26px;

  /* Telegram */
  --color-telegram:       #2AABEE;
  --color-telegram-active: #229ED9;

  /* Transitions */
  --ease-standard:    cubic-bezier(.2, .8, .2, 1);
  --transition-fast:  .15s;
  --transition-base:  .2s;
  --transition-screen: .2s;
  --transition-sheet: .3s;
  --spin-duration:    .7s;
}

/* ── Dark Theme ───────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --color-bg-start:   #000000;
  --color-bg-mid:     #18184a;
  --color-bg-end:     #12123d;
  --color-accent-dark: #0050cc;

  --surface-card:     rgba(255, 255, 255, .08);
  --surface-elevated: rgba(255, 255, 255, .10);
  --surface-hover:    rgba(255, 255, 255, .15);
  --surface-border:   rgba(255, 255, 255, .08);
  --surface-input-bg: rgba(255, 255, 255, .10);
  --surface-input-bg-focus: rgba(255, 255, 255, .13);
  --surface-accent:   rgba(0, 183, 255, .18);
  --surface-accent-selected: rgba(0, 183, 255, .14);
  --surface-danger-border: rgba(239, 68, 68, .32);

  --gradient-bg:      linear-gradient(180deg, #000000 0%, #18184a 50%, #12123d 100%);
  --gradient-primary: linear-gradient(135deg, #0050cc 0%, #0090dd 100%);
  --gradient-sheet:   linear-gradient(180deg, #14142c 0%, #0b0b16 100%);
}

/* ── Reset ────────────────────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

h1, h2, h3 {
  letter-spacing: .01em;
  line-height: 1.2;
}

html, body {
  width: 100%;
  height: 100dvh;
  font-family: var(--font-family);
  position: relative;
  background-color: var(--color-bg-start);
  background-image: var(--gradient-bg);
  color: var(--color-text);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

/* ── Layout ───────────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-screen) ease-out;
  background: transparent;
  will-change: opacity;
  /* --tg-screen-pad-top set by JS only inside Telegram; browser keeps env() */
  padding-top:    var(--tg-screen-pad-top, env(safe-area-inset-top, 0px));
  padding-left:   var(--tg-content-safe-area-inset-left, env(safe-area-inset-left, 0px));
  padding-right:  var(--tg-content-safe-area-inset-right, env(safe-area-inset-right, 0px));
  padding-bottom: var(--tg-content-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}


.screen-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--padding-screen);
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

/* ── Top Bar (shared) ─────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--padding-screen) var(--padding-screen) var(--space-2);
  position: relative;
  min-height: 56px;
}
.top-bar h1 { font-size: var(--fs-xl); font-weight: 600; }
.top-bar-title {
  flex: 1;
  text-align: center;
  font-size: var(--fs-lg);
  font-weight: 600;
}

/* Back button — default (fixed) fallback */
.top-bar .back-btn svg { width: 24px; height: 24px; }

/* ── Screen Header Bar (reusable) ─────────────────────────────────── */
/* Shared header-bar: glass card with back-btn + title + optional support-btn */
.screen-header-bar {
  width: calc(100% - 48px);
  margin: var(--padding-screen) var(--padding-screen) 0;
  padding: 0 var(--padding-card);
  box-sizing: border-box;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  overflow: hidden;
  isolation: isolate;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.screen-header-bar .back-btn,
.screen-header-bar .header-support-btn,
.screen-header-bar .header-theme-btn {
  position: static;
  width: var(--header-btn-size);
  height: var(--header-btn-size);
  border-radius: var(--radius-pill);
  border: 1px solid var(--surface-border);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast) var(--ease-standard), background var(--transition-base) var(--ease-standard);
}
.screen-header-bar .back-btn:active,
.screen-header-bar .header-support-btn:active,
.screen-header-bar .header-theme-btn:active { transform: scale(.92); }
.screen-header-bar .header-support-btn svg,
.screen-header-bar .header-theme-btn svg {
  width: 22px;
  height: 22px;
}
.screen-header-bar .header-screen-action-btn.is-loading svg {
  animation: spin var(--spin-duration) linear infinite;
}

/* Per-screen header bars — all use shared .screen-header-bar (defined above) */

#screen-benefits .screen-content.benefits-screen,
#screen-plans .screen-content.plans-screen,
#screen-profile .screen-content.profile-screen,
#screen-account .screen-content.account-screen,
#screen-devices .screen-content.devices-screen,
#screen-transactions .screen-content.transactions-screen,
#screen-invite .screen-content.invite-screen,
#screen-support .screen-content.support-screen,
#screen-support-chat .screen-content.support-chat-screen,
#screen-setup .screen-content.setup-screen,
#screen-admin .screen-content.admin-screen,
#screen-admin-stats .screen-content.admin-stats-screen,
#screen-admin-finance .screen-content.admin-finance-screen,
#screen-admin-db .screen-content.admin-tool-screen,
#screen-admin-broadcast .screen-content.admin-tool-screen,
#screen-admin-promo .screen-content.admin-tool-screen {
  padding: var(--gap) var(--padding-screen) var(--padding-screen);
  max-width: none;
  box-sizing: border-box;
}

/* ── Buttons (global) ─────────────────────────────────────────────── */
button {
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform var(--transition-fast) var(--ease-standard), background var(--transition-base) var(--ease-standard), box-shadow var(--transition-base) var(--ease-standard);
}
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.06); }
  .btn-secondary:hover { background: var(--surface-hover); }
}

.btn-primary {
  width: 100%;
  height: var(--btn-height);
  border-radius: var(--radius-btn);
  font-size: var(--fs-xl);
  font-weight: 600;
  background: var(--gradient-primary);
  border: none;
  box-shadow: none;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
}
.btn-secondary {
  width: 100%;
  height: var(--btn-height);
  border-radius: var(--radius-btn);
  font-size: var(--fs-xl);
  font-weight: 600;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  overflow: hidden;
  isolation: isolate;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Email привязан — зелёная некликабельная плашка с почтой */
.profile-btn-email-bound,
.account-btn-email-bound {
  width: 100%;
  height: auto;
  min-height: 76px;
  padding: var(--padding-btn);
  background: rgba(34, 197, 94, .35);
  border: none;
  border-radius: var(--radius-btn);
  color: var(--color-text);
  cursor: default;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
  box-sizing: border-box;
  font-family: inherit;
}
.profile-btn-email-bound .btn-icon-svg,
.account-btn-email-bound .btn-icon-svg {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-btn-email-bound .btn-icon-svg svg,
.account-btn-email-bound .btn-icon-svg svg { width: 100%; height: 100%; }
.profile-btn-email-bound .btn-email-bound-label,
.account-btn-email-bound .btn-email-bound-label {
  font-weight: 600;
  font-size: var(--fs-xl);
}
.profile-btn-email-bound .btn-email-address,
.account-btn-email-bound .btn-email-address {
  width: 100%;
  font-size: var(--fs-md);
  font-weight: 600;
  background: rgba(0, 0, 0, .35);
  padding: var(--space-3) 14px;
  border-radius: 10px;
  margin-top: var(--space-1);
  letter-spacing: .03em;
  border: 1px solid var(--surface-input-border);
}

.btn-row { display: flex; gap: var(--gap); width: 100%; }
.btn-row button { flex: 1; }
.buttons-stack { display: flex; flex-direction: column; gap: var(--gap); width: 100%; }

/* Icon-button helpers */
.btn-with-icon {
  justify-content: center;
  padding-left: var(--padding-btn);
  padding-right: var(--padding-btn);
  gap: var(--gap);
}
.btn-with-meta { justify-content: space-between; }
.btn-with-meta .btn-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.btn-with-meta .btn-meta {
  flex-shrink: 0;
  font-size: var(--fs-md);
  opacity: 0.9;
}
.btn-icon-svg {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon-svg svg { width: 100%; height: 100%; }

/* ── Cards / Glass ────────────────────────────────────────────────── */
.glass-card {
  background: var(--surface-card);
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  overflow: hidden;
  isolation: isolate;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  width: 100%;
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
}

/* Unified card surface across screens */
.home-header,
.home-stat-card,
.benefits-card,
.benefits-locations-card,
.devices-block,
.setup-block,
.profile-stat-card,
.invite-rewards-card,
.invite-count-card,
.invite-how-card,
#screen-support-chat .support-chat-messages,
.auth-form-block,
.auth-logo-block,
.auth-text-block,
.confirm-details,
.method-row,
.method-option,
.device-item,
.tx-item,
#screen-support .faq-item,
.notify-settings {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  isolation: isolate;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* ── Reusable: stat-card (used in devices + transactions) ─────────── */
.stat-card {
  border-radius: var(--radius-card);
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  isolation: isolate;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  padding: var(--padding-card);
  box-sizing: border-box;
  flex-shrink: 0;
  width: 100%;
}
.stat-card-icon {
  flex-shrink: 0;
  width: var(--icon-box);
  height: var(--icon-box);
  border-radius: var(--icon-box-radius);
  background: var(--surface-accent);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card-icon svg { width: 22px; height: 22px; }
.stat-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.stat-card-label { font-size: var(--fs-sm); color: var(--color-text-dim); }
.stat-card-value { font-size: var(--fs-xl); font-weight: 700; color: var(--color-text); }

/* ── Home Screen ──────────────────────────────────────────────────── */
#screen-home .screen-content {
  overflow: hidden;
  gap: 0;
  padding: var(--padding-screen);
  max-width: none;
  scrollbar-gutter: auto;
}

.home-header {
  width: 100%;
  margin: 0 0 var(--gap) 0;
  padding: 0 var(--padding-card);
  box-sizing: border-box;
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  flex-shrink: 0;
}
.home-header-logo {
  height: 24px;
  width: auto;
  max-width: 90px;
  object-fit: contain;
  pointer-events: none;
}
.home-header-btn {
  width: var(--header-btn-size);
  height: var(--header-btn-size);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-base) var(--ease-standard), background var(--transition-base) var(--ease-standard);
  text-decoration: none;
  font: inherit;
}
.home-header-btn:active { transform: scale(.92); }
.home-header-btn svg { width: 22px; height: 22px; }

.home-middle {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin-bottom: var(--gap);
}

.home-stats-grid {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--gap);
}
.home-stat-card {
  border-radius: var(--radius-card);
  padding: var(--space-3) 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 0;
}
.home-stat-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  flex-shrink: 0;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-stat-icon svg { width: 100%; height: 100%; }
.home-stat-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
.home-stat-value {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--color-text);
  transition: color var(--transition-base) var(--ease-standard);
}
.home-stat-value.badge-active   { color: var(--color-success); }
.home-stat-value.badge-expired  { color: var(--color-warning); }
.home-stat-value.badge-disabled { color: var(--color-danger); }

.home-bottom {
  width: 100%;
  flex-shrink: 0;
  flex-grow: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.home-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Hint overlay + spotlight */
.btn-hint-wrap { position: relative; width: 100%; }
.btn-hint {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  right: 0;
  z-index: 202;
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--color-text);
  background: var(--surface-elevated);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  padding: var(--padding-btn);
  border-radius: var(--radius-btn);
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition-sheet) ease-out, transform var(--transition-sheet) ease-out;
}
.btn-hint::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--surface-elevated);
}
.hint-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .8);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base) var(--ease-standard), visibility var(--transition-base);
}
.hint-overlay.active { opacity: 1; visibility: visible; }
.btn-hint-wrap.hint-visible {
  position: relative;
  z-index: 201;
}
.btn-hint-wrap.hint-visible .btn-hint {
  opacity: 1;
  transform: translateY(0);
}
.btn-hint-wrap.hint-visible > button {
}


/* ── Benefits Screen ──────────────────────────────────────────────── */
.benefits-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.benefits-card {
  width: 100%;
  flex-shrink: 0;
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.benefits-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.benefits-icon-box {
  flex-shrink: 0;
  width: var(--icon-box);
  height: var(--icon-box);
  border-radius: var(--icon-box-radius);
  background: var(--surface-accent);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.benefits-icon-box svg { width: 22px; height: 22px; }
.benefits-header-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.benefits-title { font-size: var(--fs-lg); font-weight: 700; color: var(--color-text); }
.benefits-hint { font-size: var(--fs-sm); color: var(--color-text-dim); }
.benefits-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.benefits-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-md);
  color: var(--color-text);
  line-height: 1.4;
}
.benefits-check {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(34, 197, 94, .15);
  color: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
}
.benefits-check svg { width: 14px; height: 14px; }
.benefits-locations-card {
  width: 100%;
  flex: 1;
  min-height: 160px;
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.benefits-locations-flags {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  flex: 1;
  min-height: 80px;
}
.benefits-loc-flag {
  border-radius: var(--icon-box-radius);
  background: var(--surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  line-height: 1;
  min-height: 0;
}
.benefits-bottom {
  width: 100%;
  flex-shrink: 0;
}

/* ── Plans Screen ─────────────────────────────────────────────────── */
.plans-screen {
  justify-content: flex-end;
  flex: 1;
  min-height: 0;
}

/* Devices selector */
.devices-block {
  width: 100%;
  height: 130px;
  box-sizing: border-box;
  flex-shrink: 0;
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  margin-bottom: var(--gap);
}
.devices-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--gap);
}
.devices-number {
  flex-shrink: 0;
  width: var(--icon-box);
  height: var(--icon-box);
  border-radius: var(--icon-box-radius);
  background: var(--surface-accent);
  color: var(--color-text);
  font-size: var(--fs-2xl);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.devices-label-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.devices-label-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.devices-label { font-size: var(--fs-lg); font-weight: 700; color: var(--color-text); }
.devices-benefit {
  display: inline-block;
  background: var(--color-danger);
  color: var(--color-text);
  font-size: 10px;
  font-weight: 700;
  padding: 3px var(--space-2);
  border-radius: 6px;
  letter-spacing: .02em;
}
.devices-sub { font-size: var(--fs-sm); color: var(--color-text-dim); width: 100%; margin-top: 2px; }

/* Slider */
.devices-slider-wrap { padding: var(--space-2) 0; position: relative; height: 48px; }
.devices-slider-track {
  position: absolute;
  left: 0; right: 0; top: 12px;
  height: 32px;
  border-radius: var(--radius-btn);
  background: var(--surface-elevated);
  overflow: hidden;
  pointer-events: none;
}
.devices-slider-dots {
  position: absolute;
  left: 14px; right: 14px; top: 0;
  height: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.devices-slider-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-text-dim);
  flex-shrink: 0;
  display: block;
  line-height: 0;
  transition: background var(--transition-fast) var(--ease-standard);
}
.devices-slider-dot.active { background: var(--color-text); }
.devices-slider {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 40px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.devices-slider::-webkit-slider-runnable-track {
  height: 32px;
  border-radius: var(--radius-btn);
  background: transparent;
}
.devices-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--color-text);
  box-shadow: var(--shadow-thumb);
  margin-top: 2px;
  cursor: pointer;
}
.devices-slider::-moz-range-track {
  height: 32px;
  border-radius: var(--radius-btn);
  background: transparent;
}
.devices-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--color-text);
  box-shadow: var(--shadow-thumb);
  border: none;
  cursor: pointer;
}

/* Plans bottom (cards + pay button) */
.plans-bottom {
  width: 100%;
  flex: 1;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.plans-bottom .plans-grid { flex: 1; min-height: 0; overflow: hidden; }

/* Plan cards grid */
.plans-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: var(--gap);
  width: 100%;
  min-height: 0;
}
@media (max-width: 360px) {
  .plans-grid { grid-template-columns: 1fr; grid-template-rows: repeat(4, 1fr); }
}

.plan-card {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  text-align: center;
  cursor: pointer;
  transition: background var(--transition-base) var(--ease-standard), border-color var(--transition-base) var(--ease-standard), box-shadow var(--transition-base) var(--ease-standard), transform var(--transition-fast) var(--ease-standard);
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.plan-card:active { transform: scale(.97); }
.plan-card.selected {
  background: rgba(0, 110, 255, .25);
  border: 1.5px solid rgba(0, 183, 255, .6);
  box-shadow: 0 0 12px rgba(0, 140, 255, .2);
}
.plan-card .plan-duration { font-size: var(--fs-base); font-weight: 600; margin-bottom: 6px; }
.plan-card .plan-price { font-size: var(--fs-2xl); font-weight: 700; }
.plan-card .plan-monthly { font-size: var(--fs-xs); color: var(--color-text-dim); margin-top: var(--space-1); }
.plan-card .plan-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-accent);
  color: var(--color-text);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 8px;
  text-transform: uppercase;
}
.plan-card .plan-badge-top {
  top: 6px;
  left: auto;
  right: 8px;
  transform: none;
  background: none;
  border: none;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

/* ── Bottom Sheet ─────────────────────────────────────────────────── */
.sheet-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .65);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base) var(--ease-standard), visibility var(--transition-base);
}
.sheet-overlay.active { opacity: 1; visibility: visible; }

.sheet {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  z-index: 101;
  background: var(--gradient-sheet);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: var(--padding-screen) max(var(--padding-screen), env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(var(--padding-screen), env(safe-area-inset-left));
  transform: translateY(100%);
  transition: transform var(--transition-sheet) var(--ease-standard);
  max-height: 85vh;
  overflow-y: auto;
}
.sheet.active { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-text-dim);
  margin: 0 auto var(--space-4);
}
.sheet-title { font-size: var(--fs-xl); font-weight: 700; margin-bottom: var(--gap); }
.sheet-section-label { font-size: var(--fs-xl); font-weight: 700; color: var(--color-text); margin-bottom: var(--gap); }
.sheet-desc {
  font-size: var(--fs-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  line-height: 1.4;
}
.sheet-form { margin-top: var(--space-2); }
.sheet-form .auth-input { margin-bottom: 0; }
.sheet-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: var(--fs-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Confirm sheet */
.confirm-details {
  background: var(--surface-card);
  border-radius: var(--radius-card);
  padding: 0 var(--padding-card);
  margin-bottom: var(--gap);
}
.confirm-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px 0;
  border-bottom: 1px solid var(--surface-border);
}
.confirm-detail-row:last-child { border-bottom: none; }
.confirm-detail-label {
  font-size: var(--fs-sm);
  color: var(--color-text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.confirm-detail-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .6;
}
.confirm-detail-value {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  text-align: right;          /* fallback for plain text values */
}
.method-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  margin-bottom: var(--gap);
  cursor: pointer;
  transition: background var(--transition-fast) var(--ease-standard);
}
.method-row:active { background: var(--surface-elevated); }
.method-row .change-btn { font-size: var(--fs-sm); color: var(--color-accent-light); font-weight: 600; }

/* Gateway icons */
.gw-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gw-icon { width: 26px; height: 26px; object-fit: contain; }
.method-option-label, .method-row .method-label { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-base); color: var(--color-text); }

/* Method picker */
.method-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--padding-card);
  border-radius: var(--radius-card);
  cursor: pointer;
  margin-bottom: var(--gap);
  transition: background var(--transition-fast) var(--ease-standard), border-color var(--transition-base) var(--ease-standard);
}
.method-option:active { background: var(--surface-elevated); }
.method-option.selected { border: 1px solid var(--color-accent-light); }
.method-option .check {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-text-dim);
}
.method-option.selected .check { border-color: var(--color-accent-light); background: var(--color-accent-light); }
.method-option:last-child { margin-bottom: 0; }

/* Waiting sheet — reuses confirm-details card */
.waiting-method-value { display: block; text-align: right; }
.waiting-method-value .gw-icon-box { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; vertical-align: middle; margin-right: 6px; }
.waiting-method-value .gw-icon { width: 18px; height: 18px; }
#waiting-status { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.waiting-status-icon { display: flex; align-items: center; flex-shrink: 0; }
.waiting-spin-svg { animation: spin var(--spin-duration) linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Sheet select (device modal) */
.sheet-select {
  width: 100%;
  padding: 14px var(--padding-card);
  background: var(--surface-input-bg);
  border: 1px solid var(--surface-input-border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-btn);
  color: var(--color-text);
  font-size: var(--fs-base);
  margin-bottom: var(--gap);
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}
.sheet-select:focus {
  border-color: var(--surface-input-focus);
  background: var(--surface-input-bg-focus);
  outline: none;
}
.sheet-select:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}
.sheet-instructions {
  background: var(--surface-card);
  border-radius: var(--radius-card);
  padding: var(--padding-card);
}
.sheet-instructions-placeholder {
  text-align: center;
  color: var(--color-text-dim);
  font-size: var(--fs-sm);
  margin: 0;
}
.sheet-instructions-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--gap);
}

/* ── Profile ──────────────────────────────────────────────────────── */
#screen-profile .screen-content.profile-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.profile-stats-grid {
  width: 100%;
  flex: 1 1 0;
  min-height: 80px;
  max-height: 180px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  gap: var(--gap);
}
.profile-stat-card {
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.profile-stat-label {
  font-size: var(--fs-md);
  color: var(--color-text-dim);
  margin-bottom: 6px;
  flex-shrink: 0;
}
.profile-stat-value {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--color-text);
}
.profile-actions { display: flex; flex-direction: column; gap: var(--gap); width: 100%; flex-shrink: 0; }
.profile-menu-list { width: 100%; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--gap); }
/* Notification settings modal */
.notify-settings {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: var(--radius-card);
  padding: 0 var(--padding-card);
}
.notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--surface-border);
}
.notify-row:last-child { border-bottom: none; }
.notify-row-info { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; }
.notify-row-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--color-text-muted); }
.notify-row-icon svg { width: 100%; height: 100%; }
.notify-row-text { display: flex; flex-direction: column; gap: 2px; }
.notify-row-label { font-size: var(--fs-sm); font-weight: 600; color: var(--color-text); }
.notify-row-desc { font-size: var(--fs-xs); color: var(--color-text-dim); }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-elevated);
  border-radius: var(--radius-sheet);
  transition: background var(--transition-base) var(--ease-standard);
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: var(--color-text);
  border-radius: 50%;
  transition: transform var(--transition-base) var(--ease-standard);
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.profile-footer-buttons { width: 100%; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--gap); }
.profile-footer-btn { text-decoration: none; text-align: center; }

/* Profile & Home: buttons left-aligned */
.profile-screen .btn-with-icon { justify-content: flex-start; }
.home-buttons .btn-with-icon:not(.btn-with-meta) { justify-content: flex-start; }

/* Logout button */
.btn-logout.hide-in-telegram { display: none !important; }
.btn-logout {
  width: 100%;
  height: var(--btn-height);
  border-radius: var(--radius-btn);
  padding: 0 var(--padding-btn);
  box-sizing: border-box;
  font-size: var(--fs-xl);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  text-align: left;
  background: var(--surface-danger-bg);
  border: 1px solid var(--surface-danger-border);
  box-shadow: var(--shadow-card);
  color: var(--color-danger);
  transition: background var(--transition-base), transform var(--transition-fast);
  flex-shrink: 0;
}
.btn-logout:active {
  transform: scale(.97);
  background: var(--surface-hover);
}
.btn-logout .btn-icon-svg {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-logout .btn-icon-svg svg { width: 100%; height: 100%; stroke: currentColor; }

/* ── Account Screen ──────────────────────────────────────────────── */
#screen-account .screen-content.account-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.account-actions { display: flex; flex-direction: column; gap: var(--gap); width: 100%; }
.account-screen .btn-with-icon { justify-content: flex-start; }

/* Email bound badge */
/* account-btn-email-bound styles consolidated with profile-btn-email-bound above */

/* ── Transactions + Devices (shared, скролл как в поддержке) ─────── */
#screen-devices .screen-content.devices-screen,
#screen-transactions .screen-content.transactions-screen {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tx-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  flex-shrink: 0;
  width: 100%;
}

/* Stat cards — now use shared .stat-card pattern (defined above) */

/* Область скролла — только список (как .support-faq-list в поддержке) */
.devices-list,
.transactions-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Device item */
.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--btn-height);
  padding: 0 var(--padding-btn);
  box-sizing: border-box;
  border-radius: var(--radius-btn);
  transition: background var(--transition-fast);
  flex-shrink: 0;
  cursor: pointer;
}
.device-item:active { background: var(--surface-elevated); }
.device-info .device-model { font-size: var(--fs-md); font-weight: 600; color: var(--color-text); }
.device-info .device-meta { font-size: var(--fs-xs); color: var(--color-text-dim); margin-top: 2px; }
.device-platform-icon { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: var(--color-text-dim); }

/* Danger button */
.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--btn-height);
  padding: 0 var(--padding-btn);
  box-sizing: border-box;
  border-radius: var(--radius-btn);
  font-size: var(--fs-base);
  font-weight: 600;
  background: var(--surface-danger-bg);
  color: var(--color-danger);
  cursor: pointer;
  border: 1px solid var(--surface-danger-border);
  box-shadow: var(--shadow-card);
  transition: background var(--transition-fast);
}
.btn-danger:active { background: var(--surface-danger-bg-hover); }

/* Transaction item */
.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--btn-height);
  padding: 0 var(--padding-btn);
  box-sizing: border-box;
  border-radius: var(--radius-btn);
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.tx-item:active { background: var(--surface-elevated); }
.tx-left .tx-amount { font-size: var(--fs-md); font-weight: 600; color: var(--color-text); }
.tx-left .tx-date { font-size: var(--fs-xs); color: var(--color-text-dim); margin-top: 2px; }
.tx-status-icon { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }

/* Transaction detail sheet */
.tx-detail-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.tx-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--surface-border);
}
.tx-detail-row:last-child { border-bottom: none; }
.tx-detail-label { font-size: var(--fs-sm); color: var(--color-text-dim); flex-shrink: 0; }
.tx-detail-value { font-size: var(--fs-md); font-weight: 600; color: var(--color-text); text-align: right; word-break: break-all; margin-left: var(--space-4); }
.tx-detail-status { display: inline-flex; align-items: center; gap: 6px; }
.tx-detail-payment-id { font-size: var(--fs-xs); font-weight: 400; font-family: monospace; color: var(--color-text-muted); }

/* ── Invite Screen ────────────────────────────────────────────────── */
#screen-invite .screen-content.invite-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Icons on accent cards (gift & percent) */
.invite-icon-white { color: var(--color-text); }

/* Combined rewards card */
.invite-rewards-card {
  width: 100%;
  flex-shrink: 0;
  border-radius: var(--radius-card);
  padding: 0 var(--padding-card);
}
.invite-reward-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--padding-card) 0;
}
.invite-reward-divider {
  height: 1px;
  background: var(--surface-border);
}

/* Invite count card — stretches to fill space */
.invite-count-card {
  width: 100%;
  flex: 1;
  min-height: 120px;
  box-sizing: border-box;
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
}
.invite-count-num {
  font-size: 56px;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}
.invite-count-label {
  font-size: var(--fs-md);
  color: var(--color-text-dim);
}

/* How-to card — mirrors .benefits-card layout */
.invite-how-card {
  width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  display: flex;
  flex-direction: column;
}
.invite-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-accent);
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.invite-link-block { width: 100%; flex-shrink: 0; }

/* ── Support ──────────────────────────────────────────────────────── */
#screen-support .screen-content.support-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.support-faq-list {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
#screen-support .faq-item {
  border-radius: var(--radius-btn);
  transition: background var(--transition-fast);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
#screen-support .faq-item.open { padding: var(--space-3) var(--padding-btn) var(--padding-btn); }
#screen-support .faq-q {
  font-size: var(--fs-xl);
  font-weight: 650;
  color: var(--color-text);
  width: 100%;
  min-height: var(--btn-height);
  padding: 0 var(--padding-btn);
  box-sizing: border-box;
  border: none;
  border-radius: var(--radius-btn);
  background: transparent;
  text-align: left;
  font-family: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap);
  cursor: pointer;
}
#screen-support .faq-q:active { background: var(--surface-hover); }
#screen-support .faq-q:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}
#screen-support .faq-q-text { flex: 1; }
#screen-support .faq-item.open .faq-q { padding-left: 0; padding-right: 0; min-height: 0; }
#screen-support .faq-a {
  font-size: var(--fs-base);
  color: var(--color-text-muted);
  margin: var(--space-2) 0 0;
  line-height: 1.6;
  display: none;
  padding-top: var(--space-2);
  border-top: 1px solid var(--surface-border);
}
#screen-support .faq-item.open .faq-a {
  display: block;
  animation: contentFadeIn var(--transition-base) ease-out;
}
#screen-support .faq-item.open .faq-arrow { transform: rotate(180deg); }
#screen-support .faq-arrow {
  transition: transform var(--transition-base) var(--ease-standard);
  font-size: var(--fs-base);
  color: var(--color-text-faint);
  flex-shrink: 0;
}
.support-contact-wrap { width: 100%; flex-shrink: 0; }

/* ── Support Chat: под шапкой плашка с сообщениями, под ней поле ввода + кнопка ── */
#screen-support-chat .screen-content.support-chat-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* 1. Плашка с сообщениями — как остальные плашки (surface-card, radius-card) */
#screen-support-chat .support-chat-messages {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--padding-btn);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  box-sizing: border-box;
}

#screen-support-chat .support-thread-placeholder {
  text-align: center;
  padding: var(--padding-screen) 0;
  color: var(--color-text-faint);
  font-size: var(--fs-base);
}

#screen-support-chat .support-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  min-width: 0;
}

#screen-support-chat .support-msg.support {
  align-self: flex-start;
  align-items: flex-start;
}

#screen-support-chat .support-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

#screen-support-chat .support-msg-body {
  font-size: var(--fs-base);
  line-height: 1.5;
  padding: var(--padding-card) var(--padding-btn);
  border-radius: var(--radius-btn);
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  box-sizing: border-box;
  white-space: pre-wrap;
}

#screen-support-chat .support-msg.user .support-msg-body {
  background: var(--gradient-primary);
  color: var(--color-text);
}

#screen-support-chat .support-msg.support .support-msg-body {
  background: var(--surface-elevated);
  color: var(--color-text);
}
#screen-support-chat .support-msg-body a {
  color: var(--color-accent-light);
  text-decoration: underline;
}
#screen-support-chat .support-msg-body a:active {
  opacity: 0.8;
}
#screen-support-chat .support-msg-body code {
  background: var(--surface-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .92em;
}
#screen-support-chat .support-msg-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 6px 0;
}
#screen-support-chat .support-msg-body pre code {
  padding: var(--space-2);
  display: block;
}

#screen-support-chat .support-msg-time {
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  margin-top: 2px;
}

/* 2. Под плашкой: поле ввода как у ссылки подписки + кнопка отправить как link-copy-btn */
#screen-support-chat .support-chat-input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: var(--gap);
  width: 100%;
  box-sizing: border-box;
}

#screen-support-chat .support-chat-input {
  flex: 1;
  min-width: 0;
  min-height: var(--btn-height);
  padding: calc((var(--btn-height) - 1.4em) / 2) var(--padding-btn);
  padding-left: 42px;
  background: var(--surface-input-bg);
  border: 1px solid var(--surface-input-border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-btn);
  color: var(--color-text);
  font-size: var(--fs-lg);
  font-weight: 600;
  font-family: inherit;
  resize: none;
  box-sizing: border-box;
  outline: none;
  line-height: 1.4;
  width: 100%;
}

#screen-support-chat .support-chat-input::placeholder {
  color: var(--color-text-dim);
}

#screen-support-chat .support-chat-input:focus {
  border-color: var(--surface-input-focus);
  background: var(--surface-input-bg-focus);
  outline: none;
}
#screen-support-chat .support-chat-input:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}

#screen-support-chat .support-chat-input.multiline {
  padding-top: var(--radius-card);
  padding-bottom: var(--radius-card);
}

#screen-support-chat .support-send-btn {
  flex-shrink: 0;
  width: var(--btn-height);
  height: var(--btn-height);
  padding: 0;
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-btn);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-base), transform var(--transition-base);
}

#screen-support-chat .support-send-btn svg {
  width: 20px;
  height: 20px;
}

#screen-support-chat .support-send-btn:active {
  transform: scale(.92);
}

#screen-support-chat .support-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Input wrap with inline attach icon ────────────────────────── */
#screen-support-chat .support-input-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: flex-end;
}
#screen-support-chat .support-input-attach {
  position: absolute;
  left: 12px;
  bottom: 0;
  height: var(--btn-height);
  width: 28px;
  padding: 0;
  background: none;
  border: none;
  color: var(--color-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition-base);
  z-index: 1;
}
#screen-support-chat .support-input-attach:active {
  color: var(--color-text);
}
#screen-support-chat .support-input-attach svg {
  width: 18px;
  height: 18px;
}

/* ── System (service) messages ─────────────────────────────────── */
#screen-support-chat .support-msg.system {
  align-self: center;
  max-width: 90%;
  text-align: center;
}
#screen-support-chat .support-msg-system-text {
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  line-height: 1.45;
  padding: 6px 14px;
  background: var(--surface-card);
  border-radius: var(--icon-box-radius);
  white-space: pre-wrap;
}

/* ── Media preview ─────────────────────────────────────────────── */
#screen-support-chat .support-chat-media-preview {
  flex-shrink: 0;
  padding: 0 var(--space-1);
}
#screen-support-chat .support-preview-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--gap);
  background: var(--surface-elevated);
  border-radius: var(--radius-btn);
  padding: 6px 10px;
  max-width: 100%;
  box-sizing: border-box;
}
#screen-support-chat .support-preview-item img {
  max-height: 72px;
  max-width: 120px;
  border-radius: 6px;
  object-fit: cover;
}
#screen-support-chat .support-preview-name {
  font-size: var(--fs-xs);
  color: var(--color-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
#screen-support-chat .support-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: var(--color-danger);
  border: none;
  border-radius: 50%;
  color: var(--color-text);
  font-size: var(--fs-base);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ── Media inside messages ─────────────────────────────────────── */
#screen-support-chat .support-msg-media {
  max-width: 100%;
  margin-bottom: var(--space-1);
}
#screen-support-chat .support-msg-media img {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius-btn);
  object-fit: contain;
  cursor: pointer;
  display: block;
}
#screen-support-chat .support-msg-media video {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius-btn);
  display: block;
}
#screen-support-chat .support-msg-media audio {
  width: 100%;
  min-width: 180px;
  max-width: 260px;
}
#screen-support-chat .support-msg-file a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-card);
  border-radius: var(--radius-btn);
  color: var(--color-accent-light);
  font-size: var(--fs-sm);
  text-decoration: none;
  word-break: break-all;
}
#screen-support-chat .support-msg-file a svg {
  flex-shrink: 0;
}
#screen-support-chat .support-msg-file a:active {
  opacity: 0.7;
}

/* ── Setup Wizard ─────────────────────────────────────────────────── */
@property --progress {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

.setup-screen { gap: var(--gap); flex: 1; min-height: 0; }
.setup-block {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-card);
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  flex-shrink: 0;
}

/* Progress border — thin line around logo card perimeter */
.setup-progress-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  border-radius: var(--radius-card);
  box-sizing: border-box;
  display: flex;
  overflow: visible;
  --progress: 0;
  transition: --progress var(--transition-sheet) ease-out;
}
.setup-progress-wrap::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: var(--space-1);
  background: conic-gradient(
    from 0deg,
    rgba(255, 255, 255, .92) calc(var(--progress) * 1%),
    rgba(255, 255, 255, .62) calc(var(--progress) * 1% + .8%),
    transparent calc(var(--progress) * 1% + 2%)
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
}
.setup-progress-wrap.progress-empty::before {
  display: none;
}
.setup-progress-wrap > .setup-logo-block {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
}

.setup-logo-block {
  flex: 1;
  min-height: 0;
  padding: var(--padding-btn);
  display: flex;
  align-items: center;
  justify-content: center;
}
.setup-bottom-block {
  flex-shrink: 0;
  width: 100%;
  height: 270px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  box-sizing: border-box;
}
.setup-bottom-block .setup-text-block { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.setup-bottom-block .buttons-stack { flex-shrink: 0; }

.setup-icon-area {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
}
.setup-icon-container { width: 130px; height: 130px; position: relative; }
.setup-icon {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(.8);
  transition: opacity var(--transition-sheet) var(--ease-standard), transform var(--transition-sheet) var(--ease-standard);
}
.setup-icon.active { opacity: 1; transform: scale(1); }
.setup-text-block { text-align: center; }
.setup-text-block h2 { font-size: var(--fs-2xl); font-weight: 600; margin: 0 0 var(--gap) 0; }
.setup-text-block p { font-size: var(--fs-base); color: var(--color-text-muted); line-height: 1.5; margin: 0; }

/* Link input + copy button row */
.link-container { display: flex; gap: var(--gap); width: 100%; align-items: stretch; }
.link-input-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}
.link-input-icon {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.link-input-icon svg { width: 100%; height: 100%; }
.link-input-wrap .link-input { padding-left: 44px; }
.link-input {
  flex: 1;
  min-width: 0;
  height: var(--btn-height);
  padding: 0 var(--padding-btn);
  background: var(--surface-input-bg);
  border: 1px solid var(--surface-input-border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-btn);
  color: var(--color-text);
  font-size: var(--fs-lg);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.link-input:focus {
  border-color: var(--surface-input-focus);
  background: var(--surface-input-bg-focus);
  outline: none;
}
.link-input:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}
.link-copy-btn {
  flex-shrink: 0;
  width: var(--btn-height);
  height: var(--btn-height);
  padding: 0;
  border-radius: var(--radius-btn);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-base), transform var(--transition-base);
}
.link-copy-btn svg { width: 20px; height: 20px; }
.link-copy-btn:active { transform: scale(.92); }
.link-copy-btn:disabled { opacity: .75; pointer-events: none; }
.link-copy-btn.copied { background: var(--color-success); }

.instruction-step {
  margin-bottom: var(--gap);
  padding-left: 20px;
  position: relative;
  line-height: 1.5;
  color: var(--color-text);
  font-size: var(--fs-base);
}
.instruction-step:before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--color-accent-light);
}

/* ── Auth Screen ──────────────────────────────────────────────────── */
#screen-auth .screen-content.auth-container {
  padding: var(--padding-screen);
  max-width: none;
  box-sizing: border-box;
  gap: 0;
}

/* Logo block — matches .setup-block .setup-logo-block exactly */
.auth-logo-block {
  flex: 1;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-logo {
  width: 140px;
  height: auto;
  pointer-events: none;
}

/* Bottom block — matches .setup-bottom-block pattern */
.auth-bottom {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-top: var(--gap);
}

/* Text/info block inside bottom — matches .setup-block .setup-text-block */
.auth-text-block {
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-card);
  padding: var(--padding-card);
  text-align: center;
}
.auth-text-block h2 {
  font-size: var(--fs-2xl);
  font-weight: 600;
  margin: 0 0 var(--gap) 0;
}
.auth-text-block p {
  font-size: var(--fs-base);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Telegram login button */
.btn-telegram {
  width: 100%;
  height: var(--btn-height);
  border-radius: var(--radius-btn);
  font-size: var(--fs-xl);
  font-weight: 600;
  background: var(--color-telegram);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  border: none;
  cursor: pointer;
  transition: background var(--transition-base);
}
.btn-telegram:active {
  background: var(--color-telegram-active);
}

/* Auth divider ("или") */
.auth-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-dim);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--surface-input-border);
}

/* Auth root (forms area) */
.auth-root {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--gap);
  text-align: center;
}

/* Auth buttons */
.auth-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Telegram widget area */
.auth-widget {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
}
.auth-placeholder { font-size: var(--fs-base); color: var(--color-text-dim); }

/* Form block (inputs inside a card) */
.auth-form-block {
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-card);
  padding: var(--padding-card);
}
.auth-form-block .auth-form-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin: 0 0 var(--space-4);
}

.auth-email-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  text-align: left;
}
.auth-email-form .auth-input,
.auth-email-form .auth-input-wrap { margin-bottom: 0; }

.auth-input-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  border-radius: var(--radius-btn);
  border: 1px solid var(--surface-input-border);
  background: var(--surface-input-bg);
  box-shadow: var(--shadow-card);
  padding: 0 10px 0 var(--padding-btn);
  transition: border-color var(--transition-base), background var(--transition-base);
}

.auth-input-wrap:focus-within {
  border-color: var(--surface-input-focus);
  background: var(--surface-input-bg-focus);
}

.auth-input {
  width: 100%;
  height: var(--btn-height);
  padding: 0;
  box-sizing: border-box;
  font-size: var(--fs-lg);
  color: var(--color-text);
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  outline: none;
  transition: border-color var(--transition-base), background var(--transition-base);
}
.auth-input::placeholder { color: var(--color-text-dim); }
.auth-input:focus {
  background: transparent;
}
.auth-input:focus-visible {
  outline: none;
}
.auth-input-action {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--icon-box-radius);
  background: transparent;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.auth-input-action svg {
  width: 22px;
  height: 22px;
}
.auth-input-action:active {
  transform: scale(.92);
}
.auth-submit-btn { margin-top: 0; }

.auth-forgot-link {
  background: none;
  border: none;
  color: var(--color-accent-light);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
  text-decoration: none;
  opacity: .85;
  transition: opacity var(--transition-fast);
  text-align: center;
}
.auth-forgot-link:active { opacity: 1; }
.auth-email-error {
  font-size: var(--fs-sm);
  color: var(--color-error);
  min-height: 0;
  text-align: center;
  margin: 0;
}
.auth-email-error:empty { display: none; }
.auth-email-hint {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin: 0;
  line-height: 1.4;
}

/* ── Shared Content Animations ────────────────────────────────────── */
@keyframes contentFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.anim-fade {
  animation: contentFadeIn var(--transition-screen) ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .sheet,
  .sheet-overlay,
  .hint-overlay,
  .btn-hint,
  .bg-layer,
  .bg-picker-overlay,
  .bg-picker,
  .bg-thumb,
  .bg-picker-btn,
  .app-loading,
  .app-toast,
  .setup-icon,
  .toggle-slider,
  .toggle-slider::before,
  .home-stat-value,
  .devices-slider-dot,
  #screen-support .faq-arrow,
  #screen-support .faq-a,
  .admin-bar-fill,
  button { transition: none !important; }

  .anim-fade,
  .waiting-spin-svg,
  .loader,
  .app-loading-spinner { animation: none !important; }
}

/* ── Utility ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-faint);
  font-size: var(--fs-base);
}
.screen-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}
.loader {
  width: 28px;
  height: 28px;
  border: 3px solid var(--surface-elevated);
  border-top-color: var(--color-text);
  border-radius: var(--radius-pill);
  animation: spin var(--spin-duration) linear infinite;
}

/* ── Desktop Containment ──────────────────────────────────────────── */
@media (min-width: 600px) {
  .screen {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    background: transparent;
  }

  .sheet {
    max-width: 520px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
  }
  .sheet.active {
    transform: translateX(-50%) translateY(0);
  }
}

/* ── Background Layer ─────────────────────────────────────────────── */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  transition: opacity var(--transition-sheet) var(--ease-standard);
}

.bg-image,
.bg-image-dim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bg-image {
  display: block;
  object-fit: cover;
}

.bg-image-dim {
  background: rgba(0, 0, 0, .45);
}

/* ── Background Picker ────────────────────────────────────────────── */
.bg-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base) var(--ease-standard);
}

.bg-picker-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.bg-picker {
  width: 100%;
  max-width: 420px;
  height: min(82vh, 760px);
  max-height: 82vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(18, 18, 42, .96);
  border: 1px solid var(--surface-border);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 28px;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .34);
  transform: translateY(100%);
  transition: transform var(--transition-sheet) var(--ease-standard);
}

.bg-picker-overlay.open .bg-picker {
  transform: translateY(0);
}

.bg-picker-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: var(--padding-btn);
}

.bg-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.bg-picker-grid::-webkit-scrollbar {
  display: none;
}

.bg-thumb {
  position: relative;
  height: 156px;
  padding: 0;
  border-radius: var(--icon-box-radius);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-base) var(--ease-standard), transform var(--transition-fast) var(--ease-standard);
  background: rgba(255, 255, 255, .03);
  appearance: none;
}

.bg-thumb:active {
  transform: scale(.97);
}

.bg-thumb.selected {
  border-color: var(--color-accent-light);
}

.bg-thumb-preview {
  width: 100%;
  height: 100%;
  border-radius: 10px;
}

.bg-thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-1) 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
  border-radius: 0 0 10px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bg-picker-actions {
  display: flex;
  gap: var(--gap);
  flex-shrink: 0;
}

.bg-picker-btn {
  flex: 1;
  height: 44px;
  border: 1px solid var(--surface-border);
  border-radius: var(--icon-box-radius);
  background: var(--surface-card);
  color: var(--color-text);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform var(--transition-fast) var(--ease-standard), background var(--transition-base) var(--ease-standard);
}

.bg-picker-btn:active {
  transform: scale(.97);
}

.bg-picker-btn.danger {
  background: var(--surface-danger-bg);
  border-color: var(--surface-danger-border);
  color: var(--color-danger);
}

/* ── App Loading Splash ───────────────────────────────────────────── */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: opacity var(--transition-sheet) ease-out;
}
.app-loading.app-loading-hidden {
  opacity: 0;
  pointer-events: none;
}
.app-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
}
.app-loading-logo {
  width: 104px;
  height: auto;
  display: block;
  object-fit: contain;
}
.app-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: var(--color-text);
  border-radius: var(--radius-pill);
  animation: spin var(--spin-duration) linear infinite;
}
.app-loading-text {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── Admin Panel ────────────────────────────────────────────────────────── */

.admin-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.admin-screen > .btn-with-icon {
  justify-content: flex-start;
}

.admin-tool-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.admin-tool-note {
  color: var(--color-text-dim);
  line-height: 1.45;
}

.admin-tool-note.is-success {
  color: var(--color-success);
}

.admin-tool-note.is-danger {
  color: var(--color-danger);
}

.admin-tool-result-card {
  width: 100%;
}

.admin-tool-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 14px var(--padding-card);
}

.admin-tool-toggle-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-tool-toggle-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--color-text);
}

.admin-tool-toggle-desc {
  font-size: var(--fs-xs);
  color: var(--color-text-dim);
}

/* admin-detail-row: unified with confirm-detail-row pattern */
.admin-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  font-size: var(--fs-base);
  color: var(--color-text-dim);
  border-bottom: 1px solid var(--surface-border);
}
.admin-detail-row:last-child { border-bottom: none; }
.admin-detail-row span:first-child { color: var(--color-text-dim); }
.admin-detail-row span:last-child {
  color: var(--color-text);
  font-weight: 600;
  text-align: right;
}

.admin-textarea {
  height: auto;
  min-height: 124px;
  padding: var(--space-3) var(--padding-btn);
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  margin-bottom: 0;
  border-radius: var(--radius-btn);
  border: 1px solid var(--surface-input-border);
  background: var(--surface-input-bg);
  box-shadow: var(--shadow-card);
}
.admin-textarea:focus {
  border-color: var(--surface-input-focus);
  background: var(--surface-input-bg-focus);
  outline: none;
}
.admin-textarea:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}

.admin-section-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-dim);
  letter-spacing: .03em;
  margin: var(--space-3) var(--space-1) var(--space-2);
  text-transform: uppercase;
}
.admin-section-title:first-child { margin-top: 0; }

.admin-bar {
  width: 100%;
  height: var(--space-2);
  background: var(--surface-elevated);
  border-radius: var(--radius-pill);
  border: 1px solid var(--surface-border);
  overflow: hidden;
  margin-bottom: var(--space-2);
}
.admin-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-pill);
  transition: width var(--transition-sheet) var(--ease-standard);
}
.admin-bar-text {
  font-size: var(--fs-sm);
  color: var(--color-text-dim);
  text-align: left;
  line-height: 1.35;
}
.admin-note-muted {
  text-align: center;
  color: var(--color-text-dim);
  font-size: var(--fs-sm);
  padding: var(--space-3) 0;
}
.admin-note-danger {
  text-align: center;
  color: var(--color-danger);
  padding: var(--space-3) 0;
}
.admin-note-subtle {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin: var(--space-2) 0 var(--space-3);
}
.admin-note-success {
  font-size: var(--fs-sm);
  color: var(--color-success);
  margin: var(--space-2) 0;
}
.admin-sync-list {
  max-height: 200px;
  overflow-y: auto;
  font-size: var(--fs-sm);
  margin-top: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-card);
}
.admin-sync-list-item {
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--surface-border);
  color: var(--color-text);
}
.admin-sync-list-item:last-child { border-bottom: none; }
.admin-sync-pre {
  font-size: var(--fs-xs);
  max-height: 160px;
  overflow: auto;
  margin-top: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-card);
}

/* ── Admin Stats Screen ──────────────────────────────────────────────── */

.admin-stats-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  flex: 1;
  min-height: 0;
}

.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  flex-shrink: 0;
  padding: var(--space-1);
  border-radius: var(--radius-card);
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
}

.period-tab {
  min-height: var(--btn-height-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--icon-box-radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-base) var(--ease-standard), color var(--transition-base) var(--ease-standard), border-color var(--transition-base) var(--ease-standard);
  font-family: inherit;
}
.period-tab:active {
  background: var(--surface-elevated);
  border-color: var(--surface-border);
}
.period-tab.active {
  background: var(--gradient-primary);
  color: var(--color-text);
  font-weight: 600;
  border-color: transparent;
}

#admin-stats-body {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  min-width: 0;
}
#screen-admin-stats .empty-state {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-card);
  padding: var(--padding-card);
}
#screen-admin-stats .screen-loader {
  min-height: 140px;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-card);
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  width: 100%;
}
.admin-stats-grid .stat-card {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.admin-stats-grid .stat-card-icon svg { width: 22px; height: 22px; }
@media (max-width: 420px) {
  .admin-stats-grid { grid-template-columns: 1fr; }
}

/* ── Admin Finance Screen ────────────────────────────────────────────── */

.admin-finance-screen {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
}

#admin-finance-body,
.admin-finance-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
}

.admin-finance-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
}

.admin-finance-shell {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
}

.admin-panel-nav {
  width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-panel-nav::-webkit-scrollbar {
  display: none;
}

.admin-panel-nav .period-tab {
  flex: 0 0 auto;
}

.admin-panel-nav .period-tab:focus,
.admin-panel-nav .period-tab:focus-visible {
  outline: none;
}

.admin-panel-nav .period-tab.active {
  background: var(--surface-elevated);
  border-color: var(--surface-border);
}

.admin-finance-panel-body,
.admin-finance-notice-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}



.admin-finance-address-card,
.admin-finance-schedule-card,
.admin-finance-history-card,
.admin-finance-notice,
.admin-finance-empty {
  width: 100%;
  min-width: 0;
}

.admin-finance-notice {
  color: var(--color-text-muted);
}

.admin-finance-notice-warning {
  border-color: rgba(245, 158, 11, .28);
  background: rgba(245, 158, 11, .12);
}

.admin-finance-notice-muted {
  color: var(--color-text-dim);
}

.admin-finance-empty {
  color: var(--color-text-dim);
}

.admin-finance-form {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
}

.admin-finance-form .admin-finance-control,
.admin-finance-form .admin-finance-select-control,
.admin-finance-form .admin-finance-textarea-control {
  margin-bottom: 0;
}

.admin-finance-control,
.admin-finance-select-control,
.admin-finance-textarea-control {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: var(--btn-height);
  padding: calc((var(--btn-height) - 1.4em) / 2) var(--padding-btn);
  color: var(--color-text);
  background: var(--surface-input-bg);
  border: 1px solid var(--surface-input-border);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-btn);
  box-sizing: border-box;
  font-size: var(--fs-lg);
  font-weight: 600;
  font-family: inherit;
  line-height: 1.4;
}

.admin-finance-select-control {
  height: var(--btn-height);
  padding: 0 var(--header-btn-size) 0 var(--padding-btn);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - var(--padding-card)) 50%;
  background-size: var(--padding-card);
}

.admin-finance-textarea-control {
  min-height: calc(var(--btn-height) * 2.2);
  padding: var(--space-3) var(--padding-btn);
  line-height: 1.5;
  resize: vertical;
}

.admin-finance-control::placeholder,
.admin-finance-textarea-control::placeholder {
  color: var(--color-text-dim);
}

.admin-finance-control:focus,
.admin-finance-select-control:focus,
.admin-finance-textarea-control:focus {
  border-color: var(--surface-input-focus);
  background: var(--surface-input-bg-focus);
  outline: none;
}

.admin-finance-control:focus-visible,
.admin-finance-select-control:focus-visible,
.admin-finance-textarea-control:focus-visible {
  outline: 2px solid var(--color-accent-light);
  outline-offset: 2px;
}

.admin-finance-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.admin-finance-field-label {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.admin-finance-field-hint {
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--color-text-dim);
}

.admin-finance-inline-note {
  font-size: var(--fs-sm);
  color: var(--color-text-dim);
  line-height: 1.45;
}

.admin-finance-inline-note.is-warning {
  color: var(--color-warning);
}

.admin-finance-inline-note.is-danger {
  color: var(--color-danger);
}

.admin-finance-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--surface-border);
  background: var(--surface-elevated);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.admin-finance-chip.is-success {
  color: var(--color-success);
  border-color: rgba(34, 197, 94, .24);
  background: rgba(34, 197, 94, .12);
}

.admin-finance-chip.is-danger {
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, .24);
  background: rgba(239, 68, 68, .12);
}

.admin-finance-chip.is-muted {
  color: var(--color-text-dim);
}

.admin-finance-address-head,
.admin-finance-schedule-head,
.admin-finance-history-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gap);
  margin-bottom: var(--space-2);
}

.admin-finance-schedule-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
}

.admin-finance-schedule-meta,
.admin-finance-history-meta,
.admin-finance-address-line {
  font-size: var(--fs-sm);
  color: var(--color-text-dim);
  line-height: 1.45;
}

.admin-finance-schedule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.admin-finance-schedule-grid span {
  display: block;
  margin-bottom: 2px;
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.admin-finance-schedule-grid strong,
.admin-finance-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.admin-finance-history-meta {
  margin-top: var(--space-2);
}

.admin-finance-actions {
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

.admin-finance-actions .btn-secondary {
  flex: 1 1 180px;
  height: var(--btn-height-sm);
  font-size: var(--fs-base);
}

@media (max-width: 520px) {
  .admin-finance-schedule-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Sheet Utility Classes (replace inline styles in index.html) ── */
.device-detail-delete-btn { margin-top: var(--space-3); }
.bind-telegram-widget {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.warning-sheet-header {
  text-align: center;
  margin-bottom: var(--padding-card);
}
.warning-sheet-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-4);
  background: rgba(255, 152, 0, .1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-3xl);
}
.warning-sheet-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.warning-sheet-desc {
  font-size: var(--fs-base);
  color: var(--color-text-muted);
}
.promo-activate-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.admin-progress {
  margin: 0;
  padding: var(--padding-card);
}
.btn-danger-soft {
  background: var(--surface-danger-bg);
  border: 1px solid var(--surface-danger-border);
  box-shadow: var(--shadow-card);
}
.btn-danger-soft:active { background: var(--surface-danger-bg-hover); }
.btn-danger-soft .btn-icon-svg { color: var(--color-danger); }
.btn-danger-soft.btn-secondary { color: var(--color-danger); }
.btn-danger-soft.btn-secondary:hover { background: var(--surface-danger-bg-hover); }
.btn-danger-soft.btn-secondary:active { background: var(--surface-danger-bg-hover); }
.btn-danger-soft-text {
  color: var(--color-danger);
  font-weight: 600;
}
#admin-promo-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.admin-promo-card {
  margin-bottom: 0;
}
.admin-promo-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gap);
  margin-bottom: var(--space-2);
}
.admin-promo-code {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-accent-light);
  background: var(--surface-accent);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--icon-box-radius);
  border: 1px solid var(--surface-accent-border);
  letter-spacing: .04em;
  white-space: nowrap;
}
.admin-promo-days {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  padding-top: var(--space-2);
}
.admin-promo-meta {
  font-size: var(--fs-sm);
  color: var(--color-text-dim);
  margin-bottom: var(--space-3);
}
.admin-promo-actions {
  display: flex;
  gap: var(--gap);
  flex-wrap: wrap;
}
.admin-promo-actions .btn-secondary {
  height: var(--btn-height-sm);
  font-size: var(--fs-base);
  flex: 1 1 auto;
}
.admin-sync-list,
.admin-sync-pre {
  border: 1px solid var(--surface-border);
  background: var(--surface-elevated);
}

/* ── In-app Toast ─────────────────────────────────────────────────── */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tg-content-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + 20px);
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - (var(--padding-screen) * 2));
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--icon-box-radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  padding: 10px 14px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base) var(--ease-standard), transform var(--transition-base) var(--ease-standard);
  background: rgba(10, 10, 10, .88);
  border: 1px solid var(--surface-border);
  color: var(--color-text);
}
@media (min-width: 600px) {
  .app-toast {
    max-width: calc(520px - (var(--padding-screen) * 2));
  }
}
.app-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.app-toast.toast-success {
  background: rgba(34, 197, 94, .15);
  border-color: rgba(34, 197, 94, .3);
  color: var(--color-success);
}
.app-toast.toast-error {
  background: var(--surface-danger-bg);
  border-color: rgba(239, 68, 68, .3);
  color: var(--color-danger);
}

#promo-code-input { text-transform: uppercase; }
#promo-code-input::placeholder { text-transform: none; }
