/* Светлая тема личного кабинета */
:root {
  --bg: #f8f9fb;
  --bg-elevated: #ffffff;
  --bg-hover: #f3f4f6;
  --surface: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #4b5563;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-active: #2563eb;
  --radius: 14px;
  --radius-sm: 12px;
  --radius-pill: 22px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  --app-max: 560px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(99, 102, 241, 0.05), transparent);
}

.app {
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 20px 12px calc(128px + var(--bottom-safe));
  display: flex;
  flex-direction: column;
}

/* Вход / регистрация: шапка только с брендом по центру (лого из /api/cabinet/logo.png) */
.app--login .header {
  display: block;
  margin-bottom: 20px;
  text-align: center;
}

.app--login .header__brand-row {
  justify-content: center;
  margin-bottom: 0;
}

.app--login .header__brand {
  justify-content: center;
  flex-wrap: wrap;
}

.app--login .header__title,
.app--login .header__user {
  display: none !important;
}

.app--login .header__logout {
  display: none !important;
}

.app--login {
  padding-top: max(48px, env(safe-area-inset-top, 0px));
}

.app--login .main {
  flex: 1;
  justify-content: center;
}

.app--login .bottom-nav {
  display: none;
}

.auth-lead {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-muted);
}

.auth-switch {
  margin: 16px 0 0;
  text-align: center;
}

.auth-switch__btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-active);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.auth-switch__btn:hover {
  color: var(--text);
}

.cabinet-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cabinet-grid > .card {
  padding: 22px 16px 24px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cabinet-grid .card__heading {
  font-size: 16px;
  margin-bottom: 14px;
}

/* Header */
.header {
  margin-bottom: 22px;
}

.header__brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--accent);
}

.header__logout {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.header__logout:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.header__logout:active {
  transform: scale(0.98);
}

.header__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  color: var(--text-muted);
}

.header__logo-img {
  display: none;
  max-height: 128px;
  width: auto;
  max-width: 640px;
  object-fit: contain;
  border-radius: 24px;
}

.header__logo-img.header__logo-img--visible {
  display: block;
}

.header__name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header__title {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.header__user {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.header__user-plain {
  color: var(--text-muted);
}

.header__user code {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Cards */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.view.view--active {
  display: flex;
}

.btn-pay {
  margin-top: 8px;
  padding: 16px 22px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-pay:hover {
  opacity: 0.95;
}

.btn-pay:active {
  transform: scale(0.99);
}

.btn-pay:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.topup-hint {
  margin: 0;
  font-size: 13px;
  color: #dc2626;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.card__subheading {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.bypass-terms-hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.bypass-terms-hint a {
  color: var(--accent-active);
}

.card__heading {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Actions (главная — Действия) */
.action-btn--bypass-banner {
  width: 100%;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  margin-bottom: 12px;
  padding: 14px 18px;
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--accent-soft);
  color: var(--text);
}

.action-btn--bypass-banner:hover {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.5);
}

.action-btn--bypass-banner .action-btn__icon {
  color: var(--accent-active);
  flex-shrink: 0;
}

.action-btn--bypass-banner .action-btn__text {
  font-weight: 600;
  font-size: 15px;
}

.grid--actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 118px;
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.action-btn:active {
  transform: scale(0.98);
}

.action-btn__icon {
  display: flex;
  color: var(--accent);
}

.action-btn__icon svg {
  width: 26px;
  height: 26px;
}

.action-btn__text {
  line-height: 1.25;
  max-width: 100%;
}

/* Нижняя панель навигации */
.bottom-dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--app-max);
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.bottom-nav {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  justify-content: stretch;
  gap: 4px;
  padding: 12px 8px calc(10px + var(--bottom-safe));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  box-sizing: border-box;
}

a.nav-item.nav-item--external {
  text-decoration: none;
  color: var(--text-muted);
}

a.nav-item.nav-item--external:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

.nav-item {
  flex: 1 1 0;
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item__label {
  line-height: 1.2;
  text-align: center;
  hyphens: auto;
}

.nav-item__icon svg {
  width: 22px;
  height: 22px;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

.nav-item--active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.22);
}

.nav-item__icon {
  display: flex;
  opacity: 0.95;
}

.nav-item--active .nav-item__icon {
  color: var(--accent-active);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(138px + var(--bottom-safe));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  max-width: 90%;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 520px) {
  .app {
    padding-top: 28px;
  }
}

/* Десктоп: чуть шире колонка по центру, без бокового меню */
@media (min-width: 768px) {
  :root {
    --app-max: 720px;
    --radius-pill: 24px;
  }

  .app {
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: calc(132px + var(--bottom-safe));
  }

  .app--login {
    padding: 48px 24px 40px;
  }

  .cabinet-grid {
    gap: 20px;
  }

  .cabinet-grid > .card {
    padding: 26px 22px 30px;
  }

  .cabinet-grid .card__heading {
    font-size: 17px;
    margin-bottom: 16px;
  }

  .grid--actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .card__heading {
    font-size: 20px;
    margin-bottom: 18px;
  }

  .action-btn {
    min-height: 128px;
    padding: 18px 12px;
    font-size: 14px;
    gap: 10px;
    border-radius: 18px;
  }

  .action-btn__icon svg {
    width: 28px;
    height: 28px;
  }

  .bottom-nav {
    padding: 14px 12px 12px;
    gap: 8px;
  }

  .nav-item {
    font-size: 12px;
    min-height: 58px;
    padding: 12px 8px;
    gap: 6px;
    border-radius: 16px;
  }

  .nav-item__icon svg {
    width: 28px;
    height: 28px;
  }

  .invite-lead {
    font-size: 15px;
  }

  .invite-stat {
    padding: 16px;
  }

  .invite-stat__label {
    font-size: 12px;
  }

  .invite-stat__value {
    font-size: 26px;
  }

  .invite-ref-row .invite-ref-input {
    font-size: 15px;
    padding: 16px 18px;
  }

  .header__logout {
    font-size: 14px;
    padding: 10px 16px;
  }

  .toast {
    bottom: calc(142px + var(--bottom-safe));
    left: auto;
    right: max(16px, calc(50% - 360px));
    transform: translateY(12px);
  }

  .toast.is-visible {
    transform: translateY(0);
  }
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  padding: 16px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  box-sizing: border-box;
}

.field-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-input--file {
  padding: 10px 12px;
  font-size: 14px;
}

.logo-upload-hint code {
  font-size: 12px;
  padding: 2px 5px;
  background: var(--surface);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.login-card,
.settings-card {
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.tariffs-loading,
.tariffs-empty {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.tariff-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tariff-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

@media (min-width: 560px) {
  .tariff-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.tariff-card__main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tariff-card__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.tariff-card__meta {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-tariff-pay {
  flex-shrink: 0;
  padding: 14px 22px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-tariff-pay:hover:not(:disabled) {
  opacity: 0.95;
}

.btn-tariff-pay:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tariffs-result {
  margin-top: 20px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
}

.tariffs-result__title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.tariffs-result__link-wrap {
  margin-bottom: 12px;
  word-break: break-all;
}

.tariffs-result__link {
  font-size: 14px;
  color: #059669;
  text-decoration: underline;
}

.btn-secondary {
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-secondary:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.vpn-loading,
.vpn-empty {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.vpn-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vpn-card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.vpn-card--inactive {
  opacity: 0.85;
  border-color: rgba(239, 68, 68, 0.25);
}

.vpn-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.vpn-card__head-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
  flex: 1;
}

.btn-copy-key--inline {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  flex-shrink: 0;
}

.vpn-card__id {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.vpn-card__id code {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--accent-active);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.vpn-card__badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
}

.vpn-card--inactive .vpn-card__badge {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.vpn-card__meta {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.vpn-card__nometa {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.vpn-card__link {
  font-size: 14px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
}

.vpn-card__link:hover {
  text-decoration: underline;
}

/* Пригласить друзей */
.invite-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.invite-lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.invite-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.invite-stat {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invite-stat__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.invite-stat__value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.invite-ref-row .invite-ref-input {
  font-size: 13px;
  word-break: break-all;
}

.invite-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invite-actions .btn-pay {
  margin-top: 0;
}

.tariffs-result__hint {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.vpn-intro {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.home-keys-card {
  margin-bottom: 0;
}

.home-keys-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.home-key-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 14px;
}

.home-key-row__id {
  font-weight: 600;
  color: var(--text);
}

.home-key-row__meta {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-home-keys-all {
  width: 100%;
}

.guide-card .guide-block-title {
  margin: 18px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.guide-card .guide-block-title:first-of-type {
  margin-top: 0;
}

.guide-device-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.guide-device-list a {
  color: #2563eb;
  text-decoration: none;
}

.guide-device-list a:hover {
  text-decoration: underline;
}

.guide-steps {
  margin: 16px 0 0;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.guide-card #btnGuidePickKey {
  margin-top: 4px;
}

.guide-keys-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + var(--bottom-safe));
}

.guide-keys-overlay[hidden] {
  display: none !important;
}

.guide-keys-panel {
  width: 100%;
  max-width: var(--app-max);
  max-height: 70vh;
  overflow: auto;
  padding: 18px 16px 16px;
  border-radius: 18px 18px 12px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  position: relative;
  box-shadow: var(--shadow);
}

.guide-keys-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.guide-keys-close:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}

.guide-keys-title {
  margin: 0 28px 14px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.guide-keys-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-keys-loading,
.guide-keys-empty {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.guide-keys-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.guide-keys-item:hover:not(:disabled) {
  border-color: rgba(147, 197, 253, 0.35);
}

.guide-keys-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.guide-keys-item__id {
  font-weight: 600;
}

.guide-keys-item__meta {
  font-size: 13px;
  color: var(--text-muted);
}
