/* ============================================================
   SAFFER — Apple-style minimal
   Dark-first, SF stack, soft elevation, rounded geometry.
   ============================================================ */

/* ===== Design tokens ===== */
:root {
  /* Surfaces — deep navy in tune with the shield logo */
  --bg-base: #06101f;
  --bg-card: #0f1d35;
  --bg-elev: #16284a;
  --bg-press: #1d3358;

  --border: rgba(120, 180, 255, 0.10);
  --border-soft: rgba(120, 180, 255, 0.06);
  --border-strong: rgba(120, 180, 255, 0.20);

  /* Text — cool white, a hair toward cyan */
  --text-primary: #eaf2ff;
  --text-secondary: rgba(220, 232, 255, 0.62);
  --text-muted: rgba(220, 232, 255, 0.46);
  --text-dim: rgba(220, 232, 255, 0.30);

  /* System colors — electric blue (logo neon) */
  --accent: #2997ff;
  --accent-hover: #4daaff;
  --accent-soft: rgba(41, 151, 255, 0.18);
  --accent-glow: rgba(41, 151, 255, 0.42);
  --accent-deep: #0a5cb8;

  --cyan: #7ee0ff;
  --cyan-soft: rgba(126, 224, 255, 0.16);

  --amber: #ffd60a;
  --amber-soft: rgba(255, 214, 10, 0.14);

  --magenta: #ff375f;
  --magenta-soft: rgba(255, 55, 95, 0.12);

  /* Semantic colors — single source of truth.
     --mint is preserved as a backward-compat alias for legacy rules; new
     code should use --success / --warning / --danger / --info. */
  --success: #30d158;
  --success-soft: rgba(48, 209, 88, 0.14);
  --warning: var(--amber);
  --warning-soft: var(--amber-soft);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.14);
  --info: var(--accent);

  /* Legacy aliases — do not introduce new uses; rules below were renamed in
     S5.3 audit. Kept so older inline-style snippets that may still reference
     these names render correctly. */
  --mint: var(--success);
  --mint-soft: var(--success-soft);
  --error: var(--danger);
  --error-soft: var(--danger-soft);

  /* Radii — Apple-ish */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  --header-h: 52px;
  --nav-h: 76px;

  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-top: env(safe-area-inset-top, 0);

  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                 "Inter", "Helvetica Neue", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", Consolas, monospace;
  --font-crt: var(--font-system); /* legacy alias */

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ===== Reset ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background:
    radial-gradient(1100px 700px at 50% -180px, rgba(41, 151, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, rgba(10, 92, 184, 0.14), transparent 65%),
    var(--bg-base);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-family: var(--font-system);
  cursor: pointer;
  letter-spacing: -0.01em;
}
a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s ease;
}
a:hover { opacity: 0.78; }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: rgba(6, 16, 31, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  height: calc(var(--header-h) + var(--safe-top));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-card);
  box-shadow: 0 0 0 1px var(--border-strong), 0 0 14px rgba(41, 151, 255, 0.32);
}
.brand-name {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--accent);
  transition: background 0.15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); }
.icon-btn:active { background: rgba(255, 255, 255, 0.10); }
.icon-btn-bell { position: relative; cursor: pointer; }
.btn-with-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-icon {
  display: inline-flex; align-items: center;
  line-height: 0;
}
.btn-icon svg { display: block; }

.bell-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--danger, #ff5d6c);
  color: #fff;
  font-size: 10px; font-weight: 600;
  border-radius: 999px;
  line-height: 1;
}
.popover-item {
  padding: 10px 12px;
  border-top: 0.5px solid var(--border);
  font-size: 13px;
}
.popover-item:first-of-type { border-top: none; }
.popover-item.unread { background: rgba(106,163,255,0.06); }
.popover-item.urgent { border-left: 2px solid var(--danger, #ff5d6c); }
.popover-item.warn { border-left: 2px solid #f3a83d; }
.popover-item-title { font-weight: 500; color: var(--text-primary); }
.popover-item-body { margin-top: 2px; color: var(--text-secondary); font-size: 12px; }
.popover-item-time { margin-top: 4px; color: var(--text-muted); font-size: 11px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 32px;
  background: var(--bg-elev);
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.lang-btn .flag { font-size: 14px; }

/* ===== Screen container ===== */
.screen-container {
  position: relative; z-index: 1;
  padding: 20px 16px calc(var(--nav-h) + var(--safe-bottom) + 24px);
  min-height: calc(100vh - var(--header-h) - var(--safe-top));
  animation: fade-in 0.28s ease;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-title {
  font-size: 28px;
  font-weight: 700;
  margin: 8px 0 4px;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  text-align: center;
}
.screen-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
  text-align: center;
}

/* ===== Card primitives ===== */
.card {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 12px; }

.card-cta {
  position: relative;
  background: linear-gradient(135deg, #2997ff 0%, #0a5cb8 100%);
  border: none;
  border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 14px;
  padding: 18px;
  cursor: pointer;
  box-shadow: 0 10px 26px -10px rgba(41, 151, 255, 0.60),
              inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.card-cta:hover {
  box-shadow: 0 16px 34px -10px rgba(41, 151, 255, 0.72),
              inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.card-cta:active { transform: scale(0.985); }
.card-cta .cta-icon {
  width: 44px; height: 44px;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px;
  flex-shrink: 0;
  color: #fff;
}
.card-cta .cta-body { flex: 1; }
.card-cta .cta-title {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: #fff;
}
.card-cta .cta-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.80);
  margin-top: 3px;
  letter-spacing: -0.005em;
}
.card-cta .cta-arrow {
  color: rgba(255, 255, 255, 0.85);
  font-size: 18px;
  font-weight: 500;
}
.card-cta .cta-arrow::before { content: "›"; font-size: 24px; line-height: 1; }

/* Welcome block */
.welcome {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 4px 0 6px;
  color: var(--text-primary);
  text-align: center;
}
.welcome-sub {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 22px;
  letter-spacing: -0.01em;
  text-align: center;
}

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  background: var(--accent-soft);
  border: none;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.005em;
}

/* Metric tiles (2-up grid) */
.metric-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-top: 14px;
}
.metric {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}
.metric-label {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: -0.005em;
}
.metric-label .arrow { color: var(--text-muted); }
.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.metric-sub {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: -0.005em;
}

/* Status active/expired panel */
.status-active {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  position: relative;
  box-shadow: var(--shadow-card);
}
.status-active .indicator {
  width: 10px; height: 10px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--mint-soft);
  flex-shrink: 0;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(48, 209, 88, 0); }
}
.status-active.warning .indicator {
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
  animation: pulse-warn 1.6s ease-in-out infinite;
}
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 214, 10, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(255, 214, 10, 0); }
}
.status-active.urgent .indicator {
  background: var(--error);
  box-shadow: 0 0 0 4px var(--error-soft);
  animation: pulse-crit 1.2s ease-in-out infinite;
}
@keyframes pulse-crit {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 69, 58, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(255, 69, 58, 0); }
}
.status-active.urgent .body .title { color: var(--error); }
.status-active .body { flex: 1; }
.status-active .body .title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.status-active .body .sub {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 2px;
  letter-spacing: -0.005em;
}

/* ===== Plan cards ===== */
.plans-list { display: flex; flex-direction: column; gap: 12px; }
.plan {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-card);
}
.plan-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.plan-icon { font-size: 18px; color: var(--accent); }
.plan-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.plan-desc {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 14px;
  letter-spacing: -0.005em;
}
.plan-price {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  letter-spacing: -0.005em;
}
.plan-price b {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  display: inline-block;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
.plan-buy {
  width: 100%; height: 46px;
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: background 0.15s ease, transform 0.12s ease;
}
.plan-buy:hover { background: var(--accent-hover); }
.plan-buy:active { transform: scale(0.985); }

/* Group badge inside plans screen */
.group-badge {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--cyan-soft);
  border: none;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}
.group-badge .ico {
  width: 36px; height: 36px;
  background: rgba(100, 210, 255, 0.20);
  border: none;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px;
  color: var(--cyan);
}
.group-badge .text .title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}
.group-badge .text .sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: -0.005em;
}

/* ===== Profile screen (key, servers) ===== */
.kv-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 0;
  border-bottom: 0.5px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-label {
  color: var(--text-secondary);
  font-size: 15px;
  letter-spacing: -0.01em;
}
.kv-value {
  font-weight: 500;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.key-box {
  background: var(--bg-elev);
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  margin: 12px 0;
  position: relative;
  line-height: 1.55;
}
.key-box::before {
  content: "Ключ подписки";
  display: block;
  font-family: var(--font-system);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: -0.005em;
}

.btn-row { display: flex; gap: 10px; }
.btn {
  flex: 1; height: 46px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.15s ease, transform 0.12s ease;
  font-family: var(--font-system);
}
.btn:active { transform: scale(0.985); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-elev);
  color: var(--accent);
  border: none;
}
.btn-secondary:hover { background: var(--bg-press); }

/* Single-action button alone in a card: stretches full width, slightly
   taller and larger type than .btn used inside .btn-row pairs. */
.btn-block {
  width: 100%;
  flex: none;
  height: 50px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Compact centered button — for secondary/dangerous actions that should be
   visible but not dominant (rotate-key, etc). Narrower than .btn-block,
   centered horizontally. */
.btn-compact {
  flex: none;
  width: auto;
  min-width: 180px;
  max-width: 260px;
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
  margin-left: auto;
  margin-right: auto;
}

/* Warning-tinted action — distinct from primary/secondary; used for things
   the user should pause before doing (key rotation invalidates all
   currently connected devices). Amber-ish on a soft amber surface. */
.btn-warning {
  background: var(--amber-soft);
  color: var(--amber);
  border: 0.5px solid rgba(255, 214, 10, 0.22);
}
.btn-warning:hover { background: rgba(255, 214, 10, 0.22); }

.server-list {
  display: flex; flex-direction: column; gap: 0;
  margin-top: 6px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.server-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--border);
  position: relative;
}
.server-item:last-child { border-bottom: none; }
.server-item .flag-name {
  display: flex; align-items: center; gap: 12px;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.server-item .ping {
  color: var(--mint);
  font-size: 13px;
  font-weight: 600;
  background: var(--mint-soft);
  border: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

/* ===== Referrals ===== */
.referral-link-card {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.referral-link {
  background: var(--bg-elev);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  margin: 12px 0;
  line-height: 1.5;
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat {
  text-align: center;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 18px 8px;
  box-shadow: var(--shadow-card);
}
.stat .num {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  letter-spacing: -0.005em;
}

/* ===== Support ===== */
.support-card {
  text-align: center;
  padding: 28px 16px;
}
.support-card .ico {
  width: 64px; height: 64px;
  background: var(--accent-soft);
  border: none;
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 30px;
  margin: 0 auto 16px;
  color: var(--accent);
}
.support-card h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.support-card p {
  color: var(--text-secondary);
  margin-bottom: 18px;
  font-size: 15px;
  letter-spacing: -0.005em;
}

/* ===== Bottom nav (iOS tab bar) ===== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(10, 22, 42, 0.82);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--border);
  padding: 8px 4px calc(var(--safe-bottom) + 6px);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: 8px;
  border: none;
  background: transparent;
  transition: color 0.15s ease;
}
.nav-item.active { color: var(--accent); }
.nav-item:active { opacity: 0.6; }

/* ===== Drawer (iOS-style sheet from right) ===== */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 60;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 300px; max-width: 84vw;
  background: #0c1932;
  border-left: 0.5px solid var(--border);
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.55);
  transform: translateX(100%);
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 70;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 14px) 0 var(--safe-bottom);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px 18px;
  border-bottom: 0.5px solid var(--border);
}
.user-avatar {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--accent) 55%, var(--accent-deep) 100%);
  border: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 18px;
  color: #fff;
  letter-spacing: -0.01em;
  box-shadow: 0 0 14px rgba(41, 151, 255, 0.45);
}
.user-name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.user-handle {
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: -0.005em;
  margin-top: 1px;
}
.drawer-header .icon-btn { margin-left: auto; }
.drawer-menu {
  display: flex; flex-direction: column;
  padding: 8px;
}
.drawer-item {
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  border: none;
  background: transparent;
  transition: background 0.15s ease;
  display: flex; align-items: center;
}
.drawer-item:hover { background: rgba(255, 255, 255, 0.06); }
.drawer-item:active { background: rgba(255, 255, 255, 0.10); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 12px 18px;
  background: rgba(22, 40, 74, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-family: var(--font-system);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* Notifications popup */
.popover {
  position: absolute;
  top: calc(var(--header-h) + var(--safe-top) + 4px); right: 14px;
  width: 300px;
  background: var(--bg-elev);
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 55;
  display: none;
}
.popover.show { display: block; }
.popover-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: -0.005em;
}
.popover-empty {
  text-align: center; padding: 24px 0;
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: -0.005em;
}
.popover-empty .ico {
  font-size: 28px; opacity: 0.4; margin-bottom: 8px;
}

/* Skeleton placeholder */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-card) 0%,
    rgba(255, 255, 255, 0.04) 50%,
    var(--bg-card) 100%);
  background-size: 200% 100%;
  border: none;
  border-radius: var(--radius-md);
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Loading + error states */
.loading-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; gap: 16px;
}
.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
  letter-spacing: -0.005em;
}
.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-block {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 40px 20px; text-align: center;
}
.error-block .error-ico {
  font-size: 36px;
  color: var(--error);
}
.error-block .error-text {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 280px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

/* Plan picker — segmented control (iOS-style) */
.device-tabs {
  display: flex; gap: 2px; margin-bottom: 20px;
  background: var(--bg-elev);
  border: none;
  padding: 2px;
  border-radius: 10px;
}
.device-tab {
  flex: 1; height: 32px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  background: transparent;
  border: none;
  transition: background 0.2s ease;
}
.device-tab.active {
  background: var(--bg-press);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  font-weight: 600;
}

/* Home — flag strip + status button */
.flag-strip {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin: 0 0 20px;
}
.flag-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: none;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  font-weight: 500;
  box-shadow: var(--shadow-card);
}

.btn-extend-inline {
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
  flex-shrink: 0;
  border: none;
}

/* Plan card extras */
.plan-flags {
  display: flex; gap: 6px;
  font-size: 18px;
  margin-bottom: 10px;
}
.chip-current {
  margin-left: auto;
  background: var(--mint-soft);
  color: var(--mint);
}
.chip-best {
  background: var(--mint-soft);
  color: var(--mint);
  box-shadow: 0 0 0 1px rgba(48, 209, 88, 0.25) inset;
}
.chip-offline {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--error-soft);
  color: var(--error);
  border: none;
  margin-left: 4px;
  border-radius: 999px;
  font-weight: 600;
}

/* Profile — rotate-key link button */
.btn-rotate-link {
  display: inline-flex; margin: 14px auto 0;
  padding: 8px 16px;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  border: none;
  border-radius: 10px;
  transition: opacity 0.15s ease;
}
.btn-rotate-link:hover { opacity: 0.7; }

/* Profile — payment history */
.payments-summary {
  list-style: none;
  padding: 16px;
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.payments-summary-arrow {
  color: var(--text-muted);
  font-size: 14px;
  transition: transform 0.2s ease;
}
details[open] .payments-summary-arrow { transform: rotate(90deg); }
.payments-list { padding: 0 16px 14px; }
.payment-row {
  display: flex; justify-content: space-between;
  padding: 12px 0;
  border-top: 0.5px solid var(--border);
  font-size: 14px;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}
.payment-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: -0.005em;
}
.btn-resume-payment {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 12px;
  border: 0.5px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
}
.btn-resume-payment:active { opacity: 0.7; }
.btn-resume-payment:disabled { opacity: 0.5; cursor: progress; }

/* Gift-ready confirmation modal — shown when a buyGift webhook fires */
.gift-ready-overlay {
  position: fixed; inset: 0;
  background: rgba(6,16,31,0.86);
  z-index: 9999;
  display: grid; place-items: center;
  padding: 24px;
}
.gift-ready-card {
  background: var(--bg-elev, #0e1726);
  border-radius: 16px;
  padding: 24px 18px;
  width: 100%; max-width: 360px;
  text-align: center;
  border: 0.5px solid var(--border);
}
.gift-ready-icon { font-size: 42px; margin-bottom: 8px; }
.gift-ready-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.gift-ready-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.gift-ready-code {
  margin: 16px auto;
  padding: 14px 18px;
  background: var(--accent-soft, rgba(106,163,255,0.10));
  border: 0.5px dashed var(--accent);
  border-radius: 10px;
  font-family: monospace;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: var(--accent);
  cursor: pointer;
}
.gift-ready-hint { font-size: 11px; color: var(--text-muted); }

.bonus-line {
  margin-top: 4px;
  color: var(--accent, #6aa3ff);
  font-size: 12px;
}
.plan-saving {
  margin-top: 4px;
  font-size: 12px;
  color: var(--success, #6affae);
  letter-spacing: -0.005em;
}
.card-cta-trial {
  background: linear-gradient(135deg, rgba(106,163,255,0.10), rgba(106,255,170,0.06));
  border: 0.5px solid rgba(106,163,255,0.20);
}
.tariff-sub {
  margin: 6px 4px 14px;
  font-size: 12px;
  color: var(--text-muted, #8aa0c0);
  letter-spacing: -0.005em;
}

/* Share screen — referral / gift tab switcher */
.share-tabs {
  display: flex; gap: 6px;
  margin: 12px 0 16px;
  padding: 4px;
  background: var(--bg-press, rgba(255,255,255,0.04));
  border-radius: 12px;
}
.share-tab {
  flex: 1;
  padding: 10px 12px;
  border: none; background: transparent;
  color: var(--text-secondary, #8aa0c0);
  font: inherit; font-size: 14px; font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
}
.share-tab.active {
  background: var(--accent-soft, rgba(106,163,255,0.16));
  color: var(--accent, #6aa3ff);
}

/* Referral details list row */
.ref-detail-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  padding: 8px 0;
  border-top: 0.5px solid var(--border);
  font-size: 13px;
}
.ref-detail-row:first-of-type { border-top: none; }
.ref-detail-handle { color: var(--text-primary); }
.ref-detail-date { color: var(--text-muted); font-size: 12px; align-self: center; }
.ref-detail-days { color: var(--accent); font-weight: 500; }

/* Gift history row */
.gift-history-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 0.5px solid var(--border);
}
.gift-history-row:first-of-type { border-top: none; }
.gift-history-code { font-family: monospace; font-size: 14px; letter-spacing: 0.5px; color: var(--text-primary); }
.gift-history-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Drawer → Документы → legal page row */
.legal-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-top: 0.5px solid var(--border);
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.legal-row:first-child { border-top: none; }
.legal-row:active { background: var(--bg-press); }
.legal-row-text { display: flex; flex-direction: column; gap: 2px; }
.legal-row-title { font-weight: 500; font-size: 14px; }
.legal-row-sub { font-size: 12px; color: var(--text-muted); }
.legal-row-arrow { color: var(--text-muted); font-size: 22px; line-height: 1; }

/* Referrals — rules text */
.rules-text {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
  letter-spacing: -0.005em;
}

/* Support */
.support-hint {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 12px;
  letter-spacing: -0.005em;
}
.ticket-input {
  width: 100%; min-height: 120px;
  padding: 14px;
  background: var(--bg-elev);
  border: none;
  border-radius: 12px;
  color: var(--text-primary);
  font: inherit;
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  resize: vertical;
  outline: none;
  transition: box-shadow 0.15s ease;
}
.ticket-input::placeholder { color: var(--text-muted); }
.ticket-input:focus {
  box-shadow: 0 0 0 2px var(--accent);
}
.support-id {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: -0.005em;
}

/* Ticket attachment picker + preview chip */
.ticket-attach-row {
  display: flex; justify-content: center;
  margin-top: 10px;
}
.btn-attach {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--bg-elev);
  color: var(--accent);
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  font-family: var(--font-system);
  transition: background 0.15s ease;
}
.btn-attach:hover { background: var(--bg-press); }
.ticket-attach-preview {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-primary);
}
.ticket-attach-size { color: var(--text-secondary); margin-left: auto; font-size: 12px; }
.ticket-attach-clear {
  background: transparent; border: none; color: var(--text-secondary);
  font-size: 16px; cursor: pointer; line-height: 1; padding: 0 4px;
}
.ticket-attach-clear:hover { color: var(--text-primary); }
.ticket-attach-progress {
  flex: 1; height: 4px;
  margin-left: auto;
  background: rgba(255,255,255,0.08);
  border-radius: 999px; overflow: hidden;
}
.ticket-attach-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 120ms linear;
}

/* Ticket thread — user reply vs operator reply */
.ticket-a-user {
  background: rgba(106,163,255,0.06);
  border-left: 2px solid var(--accent);
}
.ticket-a-time {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.ticket-reply-row {
  display: flex; gap: 8px;
  margin-top: 10px;
}
.ticket-reply-input {
  flex: 1;
  min-height: 38px; max-height: 120px;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font: inherit; font-size: 13px;
  resize: vertical;
}
.ticket-reply-btn { padding: 0 14px; }

/* Ticket history items (Support → Q&A list) */
.ticket-item {
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border);
}
.ticket-item:last-child { border-bottom: none; }
.ticket-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.ticket-num {
  font-weight: 600; font-size: 13px; color: var(--accent);
  letter-spacing: -0.01em;
}
.ticket-date {
  font-size: 12px; color: var(--text-muted);
  margin-left: auto;
}
.ticket-status {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.ticket-status-closed   { background: var(--mint-soft);   color: var(--mint); }
.ticket-status-open     { background: var(--amber-soft);  color: var(--amber); }
.ticket-status-wait     { background: var(--accent-soft); color: var(--accent); }
.ticket-status-escalated { background: var(--accent-soft); color: var(--cyan); }
.ticket-q {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 14px; line-height: 1.45;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  word-break: break-word;
}
.ticket-media-tag { flex-shrink: 0; }
.ticket-a {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 10px;
}
.ticket-a-kind {
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.ticket-a-text {
  font-size: 14px; line-height: 1.45;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  word-break: break-word;
}
.ticket-pending {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
.faq-item {
  border-bottom: 0.5px solid var(--border);
  padding: 14px 0;
}
.faq-q {
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  outline: none;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 6px;
}
.faq-q::before {
  content: "›";
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s ease;
}
details[open] .faq-q::before { transform: rotate(90deg); }
.faq-a {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 8px;
  padding-left: 18px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}

/* Balance hero */
.balance-hero {
  text-align: center;
  padding: 28px 16px;
}
.balance-label {
  color: var(--text-secondary);
  font-size: 14px;
  letter-spacing: -0.005em;
}
.balance-value {
  font-size: 56px;
  font-weight: 700;
  margin: 6px 0;
  color: var(--text-primary);
  letter-spacing: -0.035em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.balance-sub {
  color: var(--text-secondary);
  font-size: 14px;
  letter-spacing: -0.005em;
}
.promocode-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: none;
  border-radius: 12px;
  color: var(--text-primary);
  font: inherit;
  font-family: var(--font-system);
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  outline: none;
  transition: box-shadow 0.15s ease;
}
.promocode-input::placeholder {
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: -0.005em;
}
.promocode-input:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

/* Drawer extras */
.drawer-divider {
  height: 0.5px;
  background: var(--border);
  margin: 8px 14px;
}
.drawer-item-danger { color: var(--error); }
.drawer-item-danger:hover { background: var(--error-soft); }
.drawer-item-admin { color: var(--cyan); }
.drawer-item-admin:hover { background: var(--cyan-soft); }
.drawer-item svg {
  margin-right: 12px;
  flex-shrink: 0;
  opacity: 0.95;
}

/* Admin tools */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 14px;
}
.admin-stat {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-card);
}
.admin-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: -0.005em;
  font-weight: 500;
}
.admin-stat-value {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.admin-stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: -0.005em;
}

.maint-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.ticket-row, .user-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; padding: 12px 0;
  border-top: 0.5px solid var(--border);
}
.ticket-row:first-child, .user-row:first-child {
  border-top: 0; padding-top: 0;
}
.ticket-head {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: var(--text-primary);
}
.ticket-new {
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 11px;
  padding: 2px 8px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: 999px;
}
.ticket-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 5px 0 3px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  letter-spacing: -0.005em;
}
.btn-mark-read {
  background: var(--bg-elev);
  color: var(--accent);
  border: none;
  width: 32px; height: 32px;
  border-radius: 10px;
  font-size: 15px;
  flex-shrink: 0;
}
.user-badges {
  display: flex; gap: 4px; flex-shrink: 0;
}
.card-danger { background: var(--bg-card); }
.btn-danger {
  width: 100%;
  background: var(--error-soft);
  color: var(--error);
  border: none;
  padding: 13px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.005em;
}
.btn-danger:hover { background: rgba(255, 69, 58, 0.22); }

/* Tools: action grid (admin home) */
.actions-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 6px;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  box-shadow: var(--shadow-card);
}
.action-btn:hover { background: var(--bg-elev); }
.action-btn:active { transform: scale(0.98); }
.action-ico {
  font-size: 24px;
  line-height: 1;
  color: var(--accent);
}
.action-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
}

/* Tools: chip pickers (duration/devices/discount) */
.chip-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip-pick {
  padding: 8px 14px;
  background: var(--bg-elev);
  border: none;
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.15s ease;
}
.chip-pick:hover { background: var(--bg-press); }
.chip-pick-active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.chip-pick-active:hover { background: var(--accent-hover); }

/* Selection */
::selection {
  background: var(--accent-soft);
  color: var(--text-primary);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px; height: 6px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }
