:root {
  --brand-green: #0f6b57;
  --brand-green-dark: #08483c;
  --brand-green-soft: #e8f3ef;

  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #667085;
  --border: rgba(17, 24, 39, 0.08);
  --red: #d94b3d;
  --page-bg: var(--bg);
  --text-main: var(--text);
  --text-muted: var(--muted);
  --radius-button: 16px;
  --radius-card: 24px;
  --radius-panel: 28px;

  --shadow-soft: 0 8px 24px rgba(17, 24, 39, 0.05);
  --shadow-card: 0 14px 34px rgba(17, 24, 39, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--brand-green);
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--brand-green-dark);
}

button:disabled {
  opacity: 0.7;
  cursor: default;
}

input {
  width: 100%;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0 16px;
  background: #ffffff;
  color: var(--text);
  font-size: 17px;
  outline: none;
}

input:focus {
  border-color: rgba(15, 107, 87, 0.35);
  box-shadow: 0 0 0 4px rgba(15, 107, 87, 0.1);
}

label {
  font-size: 15px;
  font-weight: 700;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.app {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 24px;
}

.login-screen,
.dashboard {
  min-height: calc(100vh - 48px);
}

.login-screen {
  display: grid;
  align-content: center;
  gap: 22px;
  max-width: 430px;
  margin: 0 auto;
}

.login-screen.hidden,
.dashboard.hidden {
  display: none !important;
}

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

.brand-logo {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 12px 30px rgba(15, 107, 87, 0.16);
}

.brand h1 {
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
}

.brand p,
.eyebrow,
.card-label,
.card-info p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(18px);
}

.startup-loader {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 30px 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(18px);
}

.startup-loader p {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.startup-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(15, 107, 87, 0.15);
  border-top-color: var(--brand-green);
  border-radius: 999px;
  animation: startupSpin 0.8s linear infinite;
}

@keyframes startupSpin {
  to {
    transform: rotate(360deg);
  }
}

#phoneStep,
#smsStep,
#registerStep,
#registerPhoneStep,
#registerCodeStep {
  display: grid;
  gap: 12px;
}

#phoneStep.hidden,
#smsStep.hidden,
#registerStep.hidden,
#registerPhoneStep.hidden,
#registerCodeStep.hidden {
  display: none !important;
}

.login-form button {
  width: 100%;
}

.form-message {
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff1f0;
}

.form-message:empty {
  display: none;
}

.auth-switch {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

.auth-switch.hidden {
  display: none !important;
}

.text-button {
  min-height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--brand-green);
  box-shadow: none;
  font-size: 15px;
  font-weight: 700;
}

.text-button:hover {
  background: transparent;
  color: var(--brand-green-dark);
}

.secondary-button {
  background: #f2f4f7;
  color: #344054;
}

.secondary-button:hover {
  background: #e4e7ec;
}

.dashboard {
  display: grid;
  gap: 16px;
  align-content: start;
  padding-bottom: 108px;
}

.topbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  padding-top: 18px;
  background: transparent;
}

.topbar::before {
  content: "\1F464";
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ffffff;
  color: var(--brand-green);
  font-size: 22px;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.06);
}

.topbar > div {
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
}

.eyebrow {
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.topbar h2 {
  font-size: 30px;
  line-height: 1.05;
  font-weight: 800;
}

.ghost-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--brand-green-soft);
  color: var(--brand-green);
  box-shadow: none;
}

.ghost-button:hover {
  background: #d9ece6;
}

.bonus-card {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  min-height: 198px;
  padding: 24px;
  border-radius: 24px;
  background: var(--brand-green);
  color: #ffffff;
  box-shadow: 0 18px 38px rgba(15, 107, 87, 0.18);
}

.card-label {
  margin-bottom: 14px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
}

.bonus-card h3 {
  margin-bottom: 10px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 800;
}

#cardStatus {
  color: rgba(255, 255, 255, 0.86);
  font-weight: 600;
}

.card-balance {
  width: fit-content;
  margin-top: 22px;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.card-balance span,
.card-balance small {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.2;
}

.card-balance strong {
  display: block;
  margin: 4px 0 2px;
  color: #ffffff;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
}

.qr-box {
  position: relative;
  z-index: 2;
  width: 128px;
  height: 128px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 8px solid #ffffff;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.qr-box img,
.qr-box canvas {
  width: 112px;
  height: 112px;
}

.card-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.card-info div,
.panel {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.card-info div {
  padding: 18px;
}

.card-info p {
  margin-bottom: 6px;
}

.card-info strong {
  color: var(--text);
  font-size: 16px;
}

.panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h3 {
  font-size: 22px;
  font-weight: 800;
}

.transactions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 252px;
  overflow-y: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-radius: 18px;
  background: #f6f7f9;
}

.transaction-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-main);
  font-size: 16px;
  font-weight: 700;
}

.transaction-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.transaction-item span {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 800;
}

.transaction-item .plus {
  color: var(--brand-green);
}

.transaction-item .minus {
  color: #d94b3d;
}

.transactions::-webkit-scrollbar {
  width: 6px;
}

.transactions::-webkit-scrollbar-thumb {
  background: rgba(15, 107, 87, 0.18);
  border-radius: 999px;
}

.transactions::-webkit-scrollbar-track {
  background: transparent;
}

.contacts-panel {
  display: none;
  gap: 24px;
  margin-bottom: 108px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.dashboard.show-contacts #cardSection,
.dashboard.show-contacts .card-info,
.dashboard.show-contacts #historySection {
  display: none;
}

.dashboard.show-contacts #contactsSection {
  display: grid;
  animation: softOpen 0.22s ease-out;
}

@keyframes softOpen {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

.contacts-hero {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 12px 34px rgba(17, 24, 39, 0.06);
}

.contacts-logo-wrap {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--brand-green);
  box-shadow: 0 12px 28px rgba(15, 107, 87, 0.18);
}

.contacts-logo {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  object-fit: cover;
}

.contacts-kicker {
  margin-bottom: 5px;
  color: var(--brand-green);
  font-size: 13px;
  font-weight: 700;
}

.contacts-hero h3 {
  color: var(--text);
  font-size: 32px;
  line-height: 1.05;
  font-weight: 800;
}

.contacts-hero p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

.hero-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.hero-actions a {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #f3f7f5;
  color: var(--brand-green);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease;
}

.hero-actions a:first-child {
  background: var(--brand-green);
  color: #ffffff;
}

.hero-actions a:active,
.contact-row:active,
.azs-row:active {
  transform: scale(0.98);
}

.contacts-group {
  display: grid;
  gap: 12px;
}

.section-title {
  display: grid;
  gap: 3px;
  padding-left: 4px;
}

.section-title h4 {
  color: var(--text);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
}

.section-title h4::before {
  margin-right: 8px;
  color: var(--brand-green);
}

.contacts-group:first-of-type .section-title h4::before {
  content: "\260E";
}

.contacts-group:last-of-type .section-title h4::before {
  content: "\2316";
}

.section-title p {
  color: var(--muted);
  font-size: 15px;
}

.compact-list {
  overflow: hidden;
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.contact-row {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 16px 78px 16px 18px;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease;
}

.contact-row + .contact-row {
  border-top: 1px solid rgba(17, 24, 39, 0.06);
}

.contact-row:hover {
  background: #f8faf9;
}

.contact-row span {
  color: var(--muted);
  font-size: 15px;
}

.contact-row strong {
  color: var(--brand-green);
  font-size: 19px;
  line-height: 1.2;
  font-weight: 700;
}

.contact-row::after {
  content: "\260E";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-green-soft);
  color: var(--brand-green);
  font-size: 22px;
  transform: translateY(-50%);
}

.contact-row.mail::after {
  content: "\2709";
}

.azs-map {
  overflow: hidden;
  width: 100%;
  height: 380px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow-card);
  animation: softOpen 0.25s ease-out;
}

.azs-map iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.compact-azs-list {
  display: grid;
  gap: 10px;
}

.azs-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: transform 0.16s ease, background 0.16s ease;
}

.azs-row:hover {
  background: #f8faf9;
}

.azs-row strong {
  display: block;
  color: var(--text);
  font-size: 17px;
  line-height: 1.2;
  font-weight: 700;
}

.azs-row strong::before {
  content: "\2316  ";
  color: var(--brand-green);
}

.azs-row span {
  display: block;
  margin-top: 3px;
  color: #344054;
  font-size: 15px;
}

.azs-row em {
  color: var(--brand-green);
  font-size: 14px;
  font-style: normal;
  font-weight: 700;
}

.ios-tabbar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: min(420px, calc(100% - 28px));
  min-height: 74px;
  padding: 9px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow:
    0 18px 44px rgba(17, 24, 39, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transform: translateX(-50%);
}

.ios-tabbar-item {
  min-height: 56px;
  display: grid;
  grid-template-rows: 20px auto;
  gap: 3px;
  place-items: center;
  padding: 7px 10px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: #667085;
  box-shadow: none;
  font-size: 13px;
  line-height: 1;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.16s ease;
}

.ios-tabbar-item:hover {
  background: transparent;
}

.ios-tabbar-item:active {
  transform: scale(0.98);
}

.ios-tabbar-item.active {
  background: rgba(15, 107, 87, 0.12);
  color: var(--brand-green);
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 18px;
  line-height: 1;
}

.ios-tabbar-item.active .tab-icon {
  color: var(--brand-green);
}

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.36);
  backdrop-filter: blur(12px);
}

.qr-modal.hidden {
  display: none !important;
}

.qr-modal-content {
  display: grid;
  gap: 16px;
  justify-items: center;
  width: min(100%, 340px);
  padding: 22px;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.24);
}

.qr-modal-box {
  width: 260px;
  height: 260px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #ffffff;
}

.qr-modal-close {
  width: 100%;
}

.blocked-card .bonus-card {
  background: #667085;
}

.blocked-card #cardStatus {
  display: inline-block;
  width: fit-content;
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff1f0;
  color: var(--red);
  font-weight: 700;
}

.blocked-card .qr-box {
  opacity: 0.45;
}

.admin-page {
  display: grid;
  gap: 20px;
  align-content: start;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 12px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f2f4f7;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.admin-link:hover {
  background: #e4e7ec;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
}

.admin-search {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
}

.admin-clients {
  display: grid;
  gap: 10px;
}

.admin-client {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  background: #f7f8fa;
}

.admin-client p {
  margin-top: 4px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .app {
    padding: 18px;
  }

  .login-screen {
    min-height: calc(100vh - 36px);
  }

  .dashboard {
    gap: 14px;
  }

  .topbar {
    grid-template-columns: 48px 1fr auto;
    gap: 10px;
    padding-top: 14px;
    margin-bottom: 6px;
  }

  .topbar::before {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .topbar h2 {
    font-size: 26px;
  }

  .bonus-card {
    display: grid;
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 20px;
    padding: 22px;
  }

  .bonus-card h3 {
    font-size: 32px;
  }

  .qr-box {
    width: 148px;
    height: 148px;
    justify-self: start;
  }

  .qr-box img,
  .qr-box canvas {
    width: 132px;
    height: 132px;
  }

  .card-info,
  .admin-form,
  .admin-search {
    grid-template-columns: 1fr;
  }

  .contacts-panel {
    gap: 20px;
  }

  .contacts-hero {
    grid-template-columns: 68px 1fr;
    gap: 14px;
    padding: 18px;
    border-radius: 24px;
  }

  .contacts-logo-wrap,
  .contacts-logo {
    width: 64px;
    height: 64px;
    border-radius: 20px;
  }

  .contacts-hero h3 {
    font-size: 26px;
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .contact-row {
    padding: 15px 74px 15px 16px;
  }

  .contact-row strong {
    font-size: 18px;
  }

  .contact-row::after {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  .azs-map {
    height: 300px;
    border-radius: 24px;
  }

  .azs-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .azs-row em {
    width: fit-content;
  }
}

@media (max-width: 520px) {
  .brand h1 {
    font-size: 32px;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
  }

  .login-form {
    padding: 20px;
  }

  .panel-header h3 {
    font-size: 20px;
  }

}

@media (max-width: 390px) {
  .app {
    padding: 14px;
  }

  .bonus-card h3 {
    font-size: 28px;
  }

  .ios-tabbar {
    bottom: 12px;
    width: calc(100% - 20px);
    min-height: 70px;
    border-radius: 26px;
  }

  .ios-tabbar-item {
    min-height: 52px;
    border-radius: 18px;
    font-size: 12px;
  }
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.app {
  width: 100%;
  max-width: 920px;
  overflow-x: hidden;
}

.dashboard,
.login-screen,
.contacts-panel,
.bonus-card,
.card-info,
.panel,
.contacts-hero,
.compact-list,
.azs-map,
.compact-azs-list,
.ios-tabbar {
  max-width: 100%;
}

.contacts-hero,
.bonus-card,
.panel,
.card-info div,
.compact-list,
.azs-map,
.azs-row {
  overflow: hidden;
}

.contacts-hero {
  grid-template-columns: 72px minmax(0, 1fr);
}

.contacts-hero-text,
.contacts-hero h3,
.contacts-hero p,
.topbar h2,
.cardNumber,
#cardNumber {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ios-tabbar {
  width: min(380px, calc(100vw - 32px));
  left: 50%;
  transform: translateX(-50%);
}

.dashboard.show-contacts #contactsSection {
  animation: none;
}

.azs-map {
  animation: none;
}

@media (max-width: 720px) {
  .app {
    padding-left: 16px;
    padding-right: 16px;
  }

  .contacts-hero {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .contacts-hero h3 {
    font-size: 25px;
    line-height: 1.08;
  }

  .bonus-card {
    width: 100%;
  }

  .ios-tabbar {
    width: calc(100vw - 32px);
    max-width: 360px;
  }
}

@media (max-width: 390px) {
  .app {
    padding-left: 14px;
    padding-right: 14px;
  }

  .ios-tabbar {
    width: calc(100vw - 24px);
  }
}

.azs-map {
  position: relative;
}

.map-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: #f7f8fa;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.map-loader::before {
  content: "";
  width: 34px;
  height: 34px;
  margin-bottom: 58px;
  position: absolute;
  border: 3px solid rgba(15, 107, 87, 0.15);
  border-top-color: var(--brand-green);
  border-radius: 999px;
  animation: mapSpin 0.8s linear infinite;
}

@keyframes mapSpin {
  to {
    transform: rotate(360deg);
  }
}

#cardSection,
.card-info,
#historySection,
#contactsSection {
  animation-duration: 0.22s;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
}

.dashboard.slide-left.show-contacts #contactsSection {
  animation-name: slideFromRight;
}

.dashboard.slide-left:not(.show-contacts) #cardSection,
.dashboard.slide-left:not(.show-contacts) .card-info,
.dashboard.slide-left:not(.show-contacts) #historySection {
  animation-name: slideFromLeft;
}

.dashboard.slide-right.show-contacts #contactsSection {
  animation-name: slideFromRight;
}

.dashboard.slide-right:not(.show-contacts) #cardSection,
.dashboard.slide-right:not(.show-contacts) .card-info,
.dashboard.slide-right:not(.show-contacts) #historySection {
  animation-name: slideFromLeft;
}

@keyframes slideFromRight {
  from {
    opacity: 0;
    transform: translateX(28px);
  }

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

@keyframes slideFromLeft {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }

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

/* Adaptive polish for different phone widths */
* {
  min-width: 0;
}

.app {
  width: 100%;
  max-width: 920px;
  overflow-x: hidden;
}

.topbar {
  grid-template-columns: 48px minmax(0, 1fr) auto;
}

.topbar h2,
.contacts-hero h3,
#cardNumber,
.card-info strong,
.transaction-item strong,
.transaction-item p {
  overflow-wrap: anywhere;
  word-break: normal;
}

.bonus-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.bonus-card h3 {
  font-size: clamp(26px, 7.2vw, 34px);
  max-width: 100%;
}

.card-balance strong {
  font-size: clamp(26px, 7vw, 32px);
}

.qr-box {
  width: clamp(104px, 28vw, 128px);
  height: clamp(104px, 28vw, 128px);
  border-width: 7px;
}

.qr-box img,
.qr-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.card-info {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card-info div {
  min-width: 0;
}

.ios-tabbar {
  max-width: calc(100vw - 24px);
}

@media (max-width: 430px) {
  .app {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .topbar::before {
    width: 42px;
    height: 42px;
    font-size: 19px;
  }

  .topbar h2 {
    font-size: clamp(22px, 7vw, 28px);
  }

  .ghost-button {
    min-height: 40px;
    padding: 0 13px;
    font-size: 14px;
  }

  .bonus-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 20px;
  }

  .qr-box {
    justify-self: start;
    width: 132px;
    height: 132px;
  }

  .card-info {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
  }

  .transaction-item {
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
  }

  .transaction-item span {
    white-space: nowrap;
  }
}

@media (max-width: 360px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .bonus-card {
    padding: 18px;
    border-radius: 22px;
  }

  .qr-box {
    width: 120px;
    height: 120px;
  }

  .ios-tabbar {
    width: calc(100vw - 20px);
  }
}

/* Final mobile layout guard */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--page-bg);
}

* {
  min-width: 0;
}

.app {
  width: min(100%, 920px);
  overflow-x: hidden;
  padding-bottom: max(136px, calc(env(safe-area-inset-bottom) + 128px));
}

.dashboard {
  padding-bottom: max(150px, calc(env(safe-area-inset-bottom) + 142px));
}

.topbar {
  width: 100%;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
}

.topbar h2,
.contacts-hero h3,
.card-info strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
}

.ghost-button {
  white-space: nowrap;
}

.bonus-card {
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: clamp(14px, 3vw, 28px);
  min-height: auto;
}

.bonus-card h3 {
  max-width: 100%;
  font-size: clamp(28px, 7vw, 38px);
  line-height: 1.08;
  overflow-wrap: normal;
  word-break: normal;
}

.card-balance {
  width: fit-content;
  max-width: 100%;
  margin-top: 18px;
  padding: 12px 15px;
  border-radius: 18px;
}

.card-balance span,
.card-balance small {
  font-size: 13px;
  line-height: 1.15;
}

.card-balance strong {
  font-size: clamp(29px, 7vw, 34px);
  line-height: 1;
}

.qr-box {
  width: clamp(104px, 26vw, 132px);
  height: clamp(104px, 26vw, 132px);
  border-width: 7px;
  border-radius: 20px;
}

.qr-box img,
.qr-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.card-info {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  overflow: hidden;
}

.history-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
}

.transaction-item {
  grid-template-columns: minmax(0, 1fr) auto;
}

.transaction-item p {
  overflow-wrap: anywhere;
}

.transaction-item .minus {
  color: #d94b3d;
}

.contacts-panel {
  margin-bottom: max(170px, calc(env(safe-area-inset-bottom) + 160px));
}

.contacts-hero {
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.contacts-hero h3 {
  font-size: clamp(24px, 5.5vw, 30px);
  line-height: 1.12;
  hyphens: auto;
}

.contacts-hero p:not(.contacts-kicker) {
  display: none;
}

.ios-tabbar {
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  width: min(390px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  border-radius: 24px;
}

@media (max-width: 520px) {
  .app {
    padding: 84px 14px max(156px, calc(env(safe-area-inset-bottom) + 146px));
  }

  .login-screen,
  .dashboard {
    width: 100%;
  }

  .topbar {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
  }

  .topbar::before {
    width: 44px;
    height: 44px;
  }

  .topbar h2 {
    font-size: clamp(25px, 7.2vw, 34px);
    line-height: 1.02;
  }

  .topbar .eyebrow {
    font-size: 14px;
  }

  .ghost-button {
    min-height: 42px;
    padding: 0 15px;
    border-radius: 18px;
    font-size: 15px;
  }

  .bonus-card {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 24px;
    border-radius: 26px;
  }

  .bonus-card h3 {
    font-size: clamp(29px, 7.6vw, 42px);
  }

  .card-balance {
    margin-top: 18px;
  }

  .qr-box {
    width: clamp(104px, 26vw, 122px);
    height: clamp(104px, 26vw, 122px);
  }

  .card-info {
    grid-template-columns: 1fr;
  }

  .card-info div {
    min-height: 92px;
  }

  .panel {
    padding: 22px;
  }

  .contacts-hero {
    grid-template-columns: 64px minmax(0, 1fr);
    padding: 22px;
  }

  .contacts-logo-wrap {
    width: 64px;
    height: 64px;
  }

  .contacts-hero h3 {
    font-size: clamp(23px, 6.2vw, 29px);
  }

  .hero-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 390px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .bonus-card {
    padding: 21px;
    gap: 12px;
  }

  .bonus-card h3 {
    font-size: clamp(27px, 7.3vw, 34px);
  }

  .card-balance {
    padding: 10px 12px;
  }

  .qr-box {
    width: 98px;
    height: 98px;
    border-width: 6px;
  }

  .history-filter {
    padding: 10px;
  }

  .ios-tabbar {
    width: calc(100vw - 20px);
  }
}

@media (max-width: 350px) {
  .bonus-card {
    grid-template-columns: 1fr;
  }

  .qr-box {
    justify-self: start;
    width: 116px;
    height: 116px;
  }
}

/* Final fixes: contacts title and date picker */
.contacts-hero h3 {
  hyphens: none;
  word-break: normal;
  overflow-wrap: normal;
}

@media (max-width: 520px) {
  .contacts-hero {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .contacts-logo-wrap {
    width: 64px;
    height: 64px;
  }

  .contacts-hero h3 {
    font-size: clamp(25px, 6.4vw, 32px);
    line-height: 1.08;
    max-width: 100%;
  }
}

.qr-box {
  position: relative;
  cursor: pointer;
}

.qr-box::after {
  content: "Увеличить";
  position: absolute;
  right: -6px;
  bottom: -10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--brand-green);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.16);
}

@media (max-width: 520px) {
  .qr-box::after {
    content: "↗";
    right: -8px;
    bottom: -8px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0;
    font-size: 17px;
  }
}

/* UX hardening: safe areas, fullscreen QR, filters, empty states */
html {
  min-height: 100%;
  scroll-padding-top: max(24px, env(safe-area-inset-top));
  scroll-padding-bottom: max(130px, calc(env(safe-area-inset-bottom) + 118px));
}

body {
  min-height: 100dvh;
}

body.qr-modal-open {
  overflow: hidden;
}

.app {
  padding-top: max(28px, calc(env(safe-area-inset-top) + 24px));
  padding-bottom: max(150px, calc(env(safe-area-inset-bottom) + 138px));
}

.dashboard {
  min-height: calc(100dvh - max(56px, calc(env(safe-area-inset-top) + 48px)));
  padding-bottom: max(170px, calc(env(safe-area-inset-bottom) + 156px));
}

.contacts-panel,
.panel {
  margin-bottom: max(28px, calc(env(safe-area-inset-bottom) + 22px));
}

.contacts-panel {
  padding-bottom: max(152px, calc(env(safe-area-inset-bottom) + 138px));
}

.transactions {
  padding-bottom: 10px;
}

.ios-tabbar {
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
  min-height: 76px;
}

.history-header {
  gap: 12px;
}

.transaction-type-filter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  padding: 6px;
  border-radius: 18px;
  background: #f4f6f9;
}

.transaction-type-filter button {
  min-height: 42px;
  padding: 0 10px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  box-shadow: none;
}

.transaction-type-filter button.active {
  background: #dcefe9;
  color: var(--brand-green);
}

.empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 150px;
  padding: 26px 18px;
  border-radius: 20px;
  background: #f6f7f9;
  text-align: center;
}

.empty-state strong {
  font-size: 18px;
}

.empty-state p {
  max-width: 260px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

.qr-modal {
  z-index: 100;
  padding:
    max(24px, calc(env(safe-area-inset-top) + 18px))
    18px
    max(24px, calc(env(safe-area-inset-bottom) + 18px));
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.14), transparent 34%),
    #061c17;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.qr-modal-content {
  width: min(100%, 430px);
  min-height: min(620px, calc(100dvh - 52px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 22px;
  border-radius: 34px;
  background: transparent;
  box-shadow: none;
}

.qr-modal-title {
  order: 1;
  color: #ffffff;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  line-height: 1.08;
  text-align: center;
}

.qr-modal-box {
  order: 2;
  width: min(78vw, 340px);
  height: min(78vw, 340px);
  margin: 0 auto;
  padding: 16px;
  border: 0;
  border-radius: 34px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

.qr-modal-box img,
.qr-modal-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.qr-modal-close {
  order: 3;
  width: min(100%, 340px);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.qr-modal-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.form-message:not(.hidden) {
  display: block;
}

@media (max-width: 520px) {
  .app {
    padding-top: max(92px, calc(env(safe-area-inset-top) + 72px));
    padding-bottom: max(170px, calc(env(safe-area-inset-bottom) + 156px));
  }

  .login-screen,
  .dashboard {
    min-height: calc(100dvh - max(92px, calc(env(safe-area-inset-top) + 72px)));
  }

  .dashboard {
    padding-bottom: max(184px, calc(env(safe-area-inset-bottom) + 168px));
  }

  .panel:last-of-type,
  .contacts-panel {
    margin-bottom: max(150px, calc(env(safe-area-inset-bottom) + 132px));
  }

  .transaction-type-filter {
    gap: 5px;
  }

  .transaction-type-filter button {
    min-height: 40px;
    padding: 0 6px;
    font-size: 13px;
  }
}

/* Technical polish: stable taps, date filter, focus states */
button,
a,
.qr-box,
.ios-tabbar-item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.qr-box:focus-visible,
.ios-tabbar-item:focus-visible {
  outline: 3px solid rgba(15, 107, 87, 0.22);
  outline-offset: 3px;
}

.history-filter {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 22px;
  background: #f4f6f9;
  cursor: default;
}

.history-filter-label {
  grid-column: 1 / -1;
  padding: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.date-picker-control {
  position: relative;
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 15px;
  background: #ffffff;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.04);
}

.date-picker-control input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 46px;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.history-filter button {
  min-width: 72px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 15px;
  background: #dcefe9;
  color: var(--brand-green);
  font-size: 16px;
  font-weight: 800;
  box-shadow: none;
}

.transactions {
  overscroll-behavior: contain;
}

.contacts-hero h3 {
  font-size: clamp(24px, 5.2vw, 30px);
  line-height: 1.08;
  hyphens: none;
  overflow-wrap: normal;
  text-wrap: balance;
}

@media (max-width: 420px) {
  .history-filter {
    grid-template-columns: 1fr;
  }

  .history-filter button {
    width: 100%;
  }

  .contacts-hero h3 {
    font-size: clamp(23px, 6vw, 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
