:root {
  --bg: #004b50;
  --bg-deep: #002929;
  --accent: #2ee6c8;
  --accent-dark: #38b2a0;
  --card: #0a555a;
  --input: rgba(0, 0, 0, 0.35);
  --muted: #9ca8a8;
  --nav: #063d41;
  --surface: #0d3d3d;
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.55);
  --radius: 16px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --nav-h: calc(64px + var(--safe-bottom));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  letter-spacing: 0.01em;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* Auth pages */
.auth-bg {
  background:
    radial-gradient(circle at 0% 50%, rgba(46, 230, 200, 0.1) 0%, transparent 28%),
    radial-gradient(circle at 100% 50%, rgba(46, 230, 200, 0.12) 0%, transparent 30%),
    linear-gradient(180deg, #005555 0%, #003838 55%, #002828 100%);
  position: relative;
  overflow: hidden;
}

.auth-bg::before,
.auth-bg::after {
  content: "";
  position: absolute;
  top: 50%;
  width: min(70vw, 420px);
  height: min(70vw, 420px);
  border-radius: 50%;
  border: 1px solid rgba(46, 230, 200, 0.12);
  pointer-events: none;
  box-shadow:
    0 0 0 40px rgba(46, 230, 200, 0.06),
    0 0 0 80px rgba(46, 230, 200, 0.04),
    0 0 0 120px rgba(46, 230, 200, 0.03);
}

.auth-bg::before {
  left: 0;
  transform: translate(-55%, -50%);
}

.auth-bg::after {
  right: 0;
  transform: translate(55%, -50%);
}

.glass-card {
  background: rgba(8, 40, 40, 0.62);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.tab-active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.tab-inactive {
  color: rgba(255, 255, 255, 0.55);
}

.input-field {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  min-height: 48px;
  font-size: 16px !important; /* prevent iOS zoom */
  transition: border-color 0.2s ease, background 0.2s ease;
}

.input-field:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: rgba(0, 0, 0, 0.4);
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 78%, #000));
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.94;
}

.btn-primary:active {
  transform: scale(0.985);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.card-surface {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
}

.page-title {
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 650;
  margin-bottom: 0.7rem;
}

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

.telegram-fab {
  background: #2aabee;
  box-shadow: 0 4px 14px rgba(42, 171, 238, 0.4);
  width: 44px;
  height: 44px;
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 18s linear infinite;
}

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.star-row,
.star {
  color: #f5c518;
}

.income-green {
  color: #5dffb0;
}

.quick-icon,
.nav-active {
  color: var(--accent);
}

.nav-active .nav-glow {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 12px;
  color: var(--accent);
}

.modal-overlay {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* App shell */
.app-shell {
  width: 100%;
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.app-shell.app-page {
  min-height: 100dvh;
  padding-bottom: var(--nav-h);
}

.app-shell.app-page.no-nav {
  padding-bottom: calc(16px + var(--safe-bottom));
}

.nav-inner {
  width: 100%;
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
}

/* Bottom nav */
.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--nav) 92%, #000);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-bottom: var(--safe-bottom);
}

.app-bottom-nav .nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 6px 2px;
  font-size: 10px;
  line-height: 1.15;
  color: rgba(255, 255, 255, 0.42);
  text-align: center;
}

.app-bottom-nav .nav-link.nav-active {
  color: var(--accent);
  font-weight: 600;
}

.app-bottom-nav .nav-icon {
  width: 36px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.app-bottom-nav .nav-link.nav-active .nav-icon {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Sticky header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.app-header .brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-header .back-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.app-header .page-heading {
  position: absolute;
  left: 56px;
  right: 56px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-pad {
  padding: 12px 16px 20px;
}

.list-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}

.seg-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  margin-bottom: 14px;
}

.seg-tabs a {
  text-align: center;
  padding: 11px 8px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
}

.seg-tabs a.active {
  background: var(--accent);
  color: #fff;
}

@media (min-width: 768px) {
  body.app-body {
    background: #001a1a;
  }

  .app-shell.app-page {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 25px 60px rgba(0, 0, 0, 0.45);
    min-height: 100dvh;
  }
}

/* Toast — top right */
#toast-host {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  font-size: 14px;
  line-height: 1.4;
  color: #fff;
  opacity: 0;
  transform: translateX(18px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-hide {
  opacity: 0;
  transform: translateX(18px);
}

.toast-success {
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.toast-error {
  background: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.toast-msg {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* Extra small phones */
@media (max-width: 360px) {
  .main-pad {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-header .brand-name {
    font-size: 1rem;
  }

  .app-bottom-nav .nav-link {
    font-size: 9px;
  }
}

/* Larger phones / tablets in phone shell */
@media (min-width: 400px) {
  body {
    font-size: 16.5px;
  }

  .section-title {
    font-size: 1rem;
  }
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
