:root {
  --bg-top: #f4f8ff;
  --bg-bottom: #ecf1fb;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --stroke: rgba(115, 145, 196, 0.18);
  --text: #20314f;
  --muted: #7485a3;
  --blue: #4f91eb;
  --blue-deep: #2d6fd6;
  --green: #36a76e;
  --green-soft: #64b97f;
  --gold: #f2b940;
  --pink: #d66097;
  --shadow-lg: 0 20px 50px rgba(83, 118, 177, 0.18);
  --shadow-md: 0 14px 30px rgba(83, 118, 177, 0.16);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(143, 195, 255, 0.36), transparent 34%),
    radial-gradient(circle at top right, rgba(101, 219, 173, 0.18), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  display: flex;
  justify-content: center;
  padding: 20px 16px calc(20px + var(--safe-bottom));
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 430px);
  min-height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.topbar,
.screen-frame,
.bottom-nav {
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.72));
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #61a8ff, #2f74dc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand__title {
  font-size: 1.08rem;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: rgba(244, 248, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
}

.chevron {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 10px;
  height: 10px;
  border-left: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  transform: rotate(45deg);
}

.icon-button--dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.icon-button--dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--blue);
}

.screen-frame {
  position: relative;
  overflow: hidden;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.54));
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 34px;
  box-shadow: var(--shadow-lg);
}

.mode-banner {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 208, 112, 0.22);
  border: 1px solid rgba(232, 180, 61, 0.25);
  color: #8b6412;
  font-size: 0.95rem;
}

.mode-banner.is-hidden {
  display: none;
}

.screen {
  display: none;
  animation: fadeUp 220ms ease;
}

.screen.is-active {
  display: block;
}

.screen__title {
  margin-bottom: 16px;
  text-align: center;
  font-size: 1.55rem;
  font-weight: 700;
}

.panel {
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

.panel + .panel,
.panel + .action-grid,
.tariff-list + .primary-button,
.referral-panel + .stats-panel {
  margin-top: 14px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-card__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.2rem;
  color: #6b4a30;
  background:
    radial-gradient(circle at 35% 30%, #fff3db 0 18%, transparent 19%),
    linear-gradient(180deg, #ffe8cf, #f1d2b6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.profile-card__name {
  font-size: 1.55rem;
  font-weight: 700;
}

.profile-card__status {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(180deg, #65d66d, #3cae4c);
  position: relative;
}

.status-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 5px;
  height: 8px;
  margin: auto;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg) translate(-1px, -1px);
}

.panel__label {
  font-size: 0.95rem;
  color: var(--muted);
}

.panel__label--big {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.panel__hint {
  margin-top: 8px;
  color: var(--text);
  font-size: 1rem;
}

.panel__hint--muted {
  color: var(--muted);
}

.tariff-card__value {
  margin-top: 8px;
  font-size: 2rem;
  font-weight: 800;
  color: var(--green);
}

.key-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.key-card__meta {
  margin-top: 10px;
  font-size: 1.02rem;
}

.qr-placeholder {
  width: 88px;
  height: 88px;
  padding: 8px;
  border-radius: 16px;
  background: white;
  border: 1px solid rgba(45, 111, 214, 0.12);
  display: grid;
  place-items: center;
}

.qr-placeholder div {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #1f2c43 11%, transparent 11% 22%, #1f2c43 22% 33%, transparent 33% 44%, #1f2c43 44% 55%, transparent 55% 66%, #1f2c43 66% 77%, transparent 77% 88%, #1f2c43 88%),
    linear-gradient(#1f2c43 11%, transparent 11% 22%, #1f2c43 22% 33%, transparent 33% 44%, #1f2c43 44% 55%, transparent 55% 66%, #1f2c43 66% 77%, transparent 77% 88%, #1f2c43 88%);
  background-size: 18px 18px;
}

.primary-button,
.secondary-button,
.action-button {
  border: 0;
  border-radius: 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  min-height: 56px;
  color: #fff;
  background: linear-gradient(180deg, #5ca7ff, #2f74dc);
  box-shadow: 0 14px 24px rgba(47, 116, 220, 0.28);
}

.primary-button--wide {
  margin-top: 18px;
}

.secondary-button {
  padding: 14px 18px;
  color: #fff;
  background: linear-gradient(180deg, #66aaff, #3a7ee1);
  min-width: 110px;
}

.secondary-button--compact {
  min-width: 0;
  padding: 12px 16px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.action-tile {
  padding: 16px 14px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.action-tile.is-disabled,
.action-button.is-disabled,
.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.5;
  filter: grayscale(0.15);
  cursor: default;
  pointer-events: none;
}

.action-tile__icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 0.92rem;
  font-weight: 700;
}

.action-tile__icon--green { background: linear-gradient(180deg, #79cb90, #46a465); }
.action-tile__icon--blue { background: linear-gradient(180deg, #5ca7ff, #2f74dc); }
.action-tile__icon--gold { background: linear-gradient(180deg, #f5cb5a, #e7a92c); }
.action-tile__icon--pink { background: linear-gradient(180deg, #ec80b2, #d44d8a); }

.tariff-list {
  display: grid;
  gap: 12px;
}

.tariff-option {
  position: relative;
  padding: 20px;
  border: 1px solid var(--stroke);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  text-align: left;
}

.tariff-option__name {
  font-size: 1.65rem;
  font-weight: 700;
}

.tariff-option__sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 1rem;
}

.tariff-option__price {
  font-size: 1.6rem;
  font-weight: 800;
  white-space: nowrap;
}

.tariff-option__price span {
  font-size: 1rem;
  font-weight: 500;
}

.tariff-option--featured {
  color: white;
  background: linear-gradient(135deg, #279d6d, #58b275);
  box-shadow: 0 18px 34px rgba(52, 160, 109, 0.28);
}

.tariff-option--featured .tariff-option__sub,
.tariff-option--featured .tariff-option__price span {
  color: rgba(255, 255, 255, 0.86);
}

.tariff-option__badge {
  position: absolute;
  top: 14px;
  right: 16px;
  padding: 6px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffcf64, #f0b62e);
  color: white;
  font-size: 0.92rem;
  font-weight: 700;
}

.key-list {
  display: grid;
  gap: 14px;
}

.empty-state {
  padding: 22px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-inline {
  color: var(--muted);
  font-size: 0.95rem;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.key-item__logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 1.2rem;
}

.key-item__logo--red { background: linear-gradient(180deg, #f36b5e, #cb3c34); }
.key-item__logo--blue { background: linear-gradient(180deg, #6aafff, #3174da); }

.key-item__body {
  flex: 1;
  min-width: 0;
}

.key-item__title {
  font-size: 1.28rem;
  font-weight: 700;
}

.key-item__meta {
  margin-top: 6px;
  color: var(--muted);
}

.key-item__meta span {
  color: #3ba664;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
}

.copy-field {
  display: flex;
  gap: 10px;
}

.copy-field input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(95, 126, 182, 0.18);
  background: rgba(248, 251, 255, 0.92);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
}

.stats-panel {
  display: grid;
  gap: 14px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.referral-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.action-button {
  min-height: 54px;
  color: white;
}

.action-button--green {
  background: linear-gradient(180deg, #73c78a, #49a563);
}

.action-button--blue {
  background: linear-gradient(180deg, #5ca7ff, #2f74dc);
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 14px 12px calc(14px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.7));
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
}

.bottom-nav__item {
  border: 0;
  border-radius: 18px;
  padding: 8px 4px;
  color: #8a97b3;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bottom-nav__item span {
  font-size: 1.45rem;
}

.bottom-nav__item small {
  font-size: 0.72rem;
}

.bottom-nav__item.is-active {
  color: var(--blue-deep);
  background: rgba(93, 151, 241, 0.11);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 390px) {
  .screen-frame {
    padding: 16px;
  }

  .screen__title {
    font-size: 1.34rem;
  }

  .tariff-option {
    padding: 18px;
  }

  .tariff-option__name {
    font-size: 1.38rem;
  }

  .tariff-option__price {
    font-size: 1.32rem;
  }

  .copy-field,
  .referral-actions {
    grid-template-columns: 1fr;
    display: grid;
  }
}
