:root {
  color-scheme: dark;
  --bg: #0a0f1a;
  --panel: #111827;
  --panel-2: #172132;
  --text: #edf3ff;
  --muted: #9dafcf;
  --accent: #67e8f9;
  --line: rgba(157, 175, 207, 0.16);
  --danger: #ff7b7b;
}

* {
  box-sizing: border-box;
}

html[dir="rtl"] body,
body.rtl {
  direction: rtl;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  background: linear-gradient(180deg, #08111f 0%, #0d1526 100%);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow-x: hidden;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 15, 26, 0.94);
  backdrop-filter: blur(10px);
}

.topbar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex: 1;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
  padding: 0.62rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(103, 232, 249, 0.1);
  background: rgba(23, 33, 50, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

.nav-link:hover {
  color: var(--text);
  background: rgba(103, 232, 249, 0.08);
  border-color: rgba(103, 232, 249, 0.18);
}

.nav-link.active {
  color: #07111d;
  background: var(--accent);
  border-color: rgba(103, 232, 249, 0.32);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(103, 232, 249, 0.18);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.05rem;
}

.subtitle {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.lang-toggle,
.topbar-auth-link,
.primary-cta,
.secondary-cta,
.corner-login {
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.62rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.lang-toggle {
  background: var(--panel-2);
  cursor: pointer;
}

.topbar-auth-link,
.secondary-cta,
.corner-login {
  background: rgba(23, 33, 50, 0.86);
}

.primary-cta,
.search button {
  background: var(--accent);
  color: #07111d;
  border-color: rgba(103, 232, 249, 0.28);
}

.search {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.search input,
.search button,
.auth-form input,
.auth-form button {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0.62rem 0.8rem;
  font-size: 0.86rem;
}

.search input {
  min-width: 210px;
}

.search button,
.auth-form button,
.lang-toggle {
  cursor: pointer;
}

.page {
  padding: 1rem 1.2rem 1.3rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.compact-hero h1,
.section-head h2 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.coin-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.coin-watch-btn {
  border-radius: 10px;
  border: 1px solid rgba(103, 232, 249, 0.22);
  background: rgba(103, 232, 249, 0.12);
  color: var(--accent);
  padding: 0.42rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.compact-hero p,
.section-head span,
.section-subnote,
.hero-subnote {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.grid {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.four-col {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dense-grid,
.tight-grid {
  align-items: start;
}

.meta-grid,
.kv-grid {
  display: grid;
  gap: 0.5rem;
}

.meta-grid {
  grid-template-columns: repeat(2, minmax(150px, 1fr));
}

.kv-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-grid div,
.kv-grid div,
.stat-card,
.meta-link-card {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.meta-grid span,
.kv-grid span,
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 0.24rem;
}

.field-label {
  display: block;
  width: fit-content;
}

.field-label.has-help-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.meta-grid strong,
.kv-grid strong,
.stat-card strong,
.meta-link-card strong {
  display: block;
  width: 100%;
  font-size: 0.87rem;
  font-weight: 700;
  line-height: 1.35;
}

.meta-link-card {
  text-decoration: none;
  border: 1px solid rgba(38, 186, 255, 0.18);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.meta-link-card:hover {
  transform: translateY(-1px);
  border-color: rgba(38, 186, 255, 0.38);
  background: rgba(34, 51, 78, 0.95);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.telegram-card {
  justify-content: center;
}

.meta-link-card strong {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.telegram-link-row {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: auto;
}

.telegram-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  flex: 0 0 14px;
  border-radius: 999px;
  background-image: url('/static/telegram-icon.svg');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.compact-stat {
  padding: 0.55rem 0.65rem;
}

.full {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: baseline;
  margin-bottom: 0.55rem;
}

.label-text {
  display: inline;
}

.help-icon {
  margin: 0 0 0 0.1rem;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 999px;
  border: 1.5px solid #67e8f9;
  background: transparent;
  color: #67e8f9;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  padding: 0;
  line-height: 1;
  box-shadow: none;
  flex: 0 0 auto;
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.help-icon:hover {
  background: rgba(103, 232, 249, 0.12);
  border-color: #9ff4ff;
  color: #9ff4ff;
  transform: translateY(-1px);
}

.help-icon span {
  display: block;
  transform: translateY(-0.3px);
}

.table-wrap {
  overflow: auto;
}

.compact-table-wrap {
  max-height: 430px;
}

.dense-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid var(--line);
}

html[dir="rtl"] th,
html[dir="rtl"] td,
body.rtl th,
body.rtl td {
  text-align: right;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(255,255,255,0.015);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.26rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-weight: 700;
}

.state-long,
.text-long {
  color: #7ff7b0;
}

.state-short,
.text-short {
  color: #ff9f9f;
}

.state-neutral,
.text-neutral {
  color: #ffd27a;
}

.venue-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.venue-badge {
  border-radius: 999px;
  padding: 0.18rem 0.45rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.plain-list {
  margin: 0;
  padding-left: 1rem;
}

html[dir="rtl"] .plain-list,
body.rtl .plain-list {
  padding-left: 0;
  padding-right: 1rem;
}

.watchlist-actions,
.watchlist-input-group,
.auth-links {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}

.watchlist-actions {
  justify-content: space-between;
  margin-top: 0.8rem;
}

.watchlist-input-group input {
  min-width: 180px;
}

.watchlist-note {
  color: var(--muted);
}

.table-remove-btn,
.mini-watch-btn {
  border: 1px solid rgba(103, 232, 249, 0.16);
  background: rgba(103, 232, 249, 0.08);
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  padding: 0.15rem 0.42rem;
}

.exchange-error,
.auth-error {
  color: #ffd3d3;
  background: rgba(255, 123, 123, 0.12);
  border: 1px solid rgba(255, 123, 123, 0.24);
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
}

.landing-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(103, 232, 249, 0.16), transparent 28%),
    radial-gradient(circle at left center, rgba(65, 105, 225, 0.14), transparent 25%),
    linear-gradient(180deg, #07111d 0%, #0d1526 100%);
}

.landing-topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem 1.5rem 0;
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(17, 24, 39, 0.72);
  font-weight: 800;
}

.landing-logo {
  width: 34px;
  height: 34px;
}

.corner-login {
  position: absolute;
  top: 1.1rem;
}

.corner-login-left {
  left: 1.5rem;
}

.corner-login-right {
  right: 1.5rem;
}

.landing-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.2rem 1.5rem 2rem;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 1.1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.landing-copy,
.landing-panel,
.landing-card,
.auth-card {
  background: rgba(17, 24, 39, 0.82);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.landing-copy {
  padding: 1.45rem;
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(103, 232, 249, 0.1);
  border: 1px solid rgba(103, 232, 249, 0.18);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
}

.landing-copy h1 {
  margin: 0.85rem 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.02;
}

.landing-lead {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 680px;
}

.landing-cta-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1.15rem;
}

.landing-panel {
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.landing-stat {
  border-radius: 14px;
  padding: 0.9rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.landing-stat span {
  display: block;
  color: var(--muted);
  margin-bottom: 0.22rem;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.landing-card {
  padding: 1.05rem;
}

.landing-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.landing-card p {
  margin: 0;
  color: var(--muted);
}

.auth-shell {
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(460px, 100%);
  padding: 1.2rem;
}

.auth-head h1 {
  margin: 0.8rem 0 0.35rem;
}

.auth-head p {
  margin: 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
}

.auth-links {
  margin-top: 1rem;
}

@media (max-width: 980px) {
  .topbar,
  .landing-hero,
  .landing-grid,
  .two-col,
  .three-col,
  .four-col {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .topbar-nav {
    justify-content: flex-start;
  }
}

.mobile-tabbar {
  display: none;
}

.mobile-tab {
  text-decoration: none;
}

@media (max-width: 720px) {
  .page,
  .landing-shell {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .page,
  .landing-shell {
    padding-bottom: calc(6.2rem + env(safe-area-inset-bottom, 0px));
  }

  .landing-topbar {
    padding-top: 1rem;
  }

  .corner-login-left {
    left: 0.9rem;
  }

  .corner-login-right {
    right: 0.9rem;
  }

  .search input {
    min-width: 0;
    width: 100%;
  }

  .search {
    width: 100%;
  }

  .topbar {
    padding-bottom: 0.9rem;
  }

  .topbar-nav {
    display: none;
  }

  .topbar-actions {
    width: 100%;
  }

  .hero,
  .landing-hero,
  .section-head,
  .watchlist-actions,
  .watchlist-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .meta-grid,
  .kv-grid,
  .landing-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .dense-card,
  .watchlist-card,
  .grid > *,
  .table-wrap,
  .compact-table-wrap {
    min-width: 0;
    max-width: 100%;
  }

  .table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    direction: rtl;
    padding-bottom: 0.2rem;
  }

  .table-wrap > * {
    direction: inherit;
  }

  .compact-table-wrap {
    max-height: none;
  }

  .dense-table {
    min-width: max-content;
    width: max-content;
    white-space: nowrap;
    font-size: 0.68rem;
    table-layout: auto;
  }

  #watchlist-table,
  #strongest-coins-table,
  #compatible-symbols-table,
  #best-opportunities-table,
  #top-volatility-table,
  .exchange-table,
  #exchange-flow-table {
    width: max-content;
    min-width: max-content;
  }

  #watchlist-table {
    min-width: 100%;
  }

  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(64px, 1fr);
    gap: 0.38rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.55rem 0.65rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    background: rgba(8, 17, 31, 0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 50;
    align-items: stretch;
  }

  .mobile-tabbar::-webkit-scrollbar {
    display: none;
  }

  .mobile-tab {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    padding: 0.3rem 0.42rem;
    border-radius: 11px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--muted);
    font-size: 0.58rem;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  }

  .mobile-tab.active {
    background: rgba(103, 232, 249, 0.14);
    color: var(--text);
    border-color: rgba(103, 232, 249, 0.24);
  }

  .mobile-tab-icon {
    font-size: 0.74rem;
    line-height: 1;
    flex: 0 0 auto;
    opacity: 0.92;
  }

  th,
  td {
    padding: 0.38rem 0.34rem;
  }

  #strongest-coins-table th,
  #strongest-coins-table td,
  #compatible-symbols-table th,
  #compatible-symbols-table td,
  #best-opportunities-table th,
  #best-opportunities-table td,
  #top-volatility-table th,
  #top-volatility-table td,
  .exchange-table th,
  .exchange-table td,
  #exchange-flow-table th,
  #exchange-flow-table td {
    white-space: nowrap;
  }

  .pill,
  .venue-badge,
  .table-remove-btn,
  .mini-watch-btn {
    font-size: 0.64rem;
  }

  .coin-title-row,
  .section-head {
    gap: 0.45rem;
  }
}
