:root {
  --bg: #f8f8f7;
  --card: #ffffff;
  --card2: #fafafa;
  --text: #151515;
  --muted: #747474;
  --border: #e7e7e7;
  --primary: #ff6a00;
  --primary2: #ffb000;
  --danger: #ef4444;
  --green: #16a34a;
  --shadow: 0 18px 45px rgba(20,20,20,.10);
}

body.dark {
  --bg: #070707;
  --card: #121212;
  --card2: #181818;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --border: #262626;
  --primary: #ff7a18;
  --primary2: #ff4d00;
  --shadow: 0 22px 60px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  background:
    radial-gradient(circle at top left, rgba(255,106,0,.16), transparent 34%),
    radial-gradient(circle at top right, rgba(255,176,0,.12), transparent 30%),
    var(--bg);
}

body.rtl { direction: rtl; }

input, select, button {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 16px 17px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

input, select {
  background: var(--card);
  color: var(--text);
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255,106,0,.13);
}

button {
  cursor: pointer;
  font-weight: 850;
}

button:disabled {
  opacity: .55;
  cursor: wait;
}

.primary-btn {
  border: 0;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 14px 28px rgba(255,106,0,.25);
}

.soft-btn {
  background: var(--card2);
  color: var(--text);
}

.logout-btn {
  background: rgba(239,68,68,.12);
  color: var(--danger);
}

.full { width: 100%; }

/* LOGIN */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: min(450px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 34px;
  padding: 38px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo-img {
  width: 104px;
  height: 104px;
  object-fit: contain;
  margin: 0 auto 18px;
  filter: drop-shadow(0 14px 28px rgba(255,106,0,.35));
}

.login-card h1 {
  margin: 0;
  font-size: 36px;
  letter-spacing: -1px;
}

.login-card p {
  color: var(--muted);
  margin: 8px 0 24px;
  font-weight: 650;
}

.login-card input {
  margin-bottom: 12px;
}

/* APP */

.app-page {
  display: none;
  min-height: 100vh;
  padding-bottom: 92px;
  overflow-x: hidden;
  touch-action: pan-y;
}

.app-header {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: relative;
  z-index: 70;
}

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

.main-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(255,106,0,.35));
}

.brand-title h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -1px;
}

.brand-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

/* BETTER MENU */

.menu-toggle {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 13px;
  backdrop-filter: blur(16px);
}

.menu-toggle span {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  display: block;
}

.settings-menu {
  position: absolute;
  top: 82px;
  right: 0;
  width: 220px;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 120;
  backdrop-filter: blur(20px);
}

body.rtl .settings-menu {
  right: auto;
  left: 0;
}

.settings-menu.open {
  display: grid;
  gap: 10px;
}

.settings-menu select,
.settings-menu button {
  height: 46px;
  border-radius: 15px;
  font-size: 14px;
  padding: 10px 13px;
}

/* CONTENT */

.content {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.balance-card {
  background: linear-gradient(135deg, #ff7a18, #ff4d00);
  color: white;
  border-radius: 34px;
  padding: 34px 28px;
  box-shadow: 0 25px 70px rgba(255,106,0,.25);
  margin-bottom: 22px;
  text-align: center;
  display: grid;
  place-items: center;
  min-height: 220px;
}

.balance-card span {
  opacity: .92;
  display: block;
  font-size: 16px;
  font-weight: 750;
}

.balance-card strong {
  font-size: clamp(42px, 7vw, 76px);
  line-height: 1.05;
  display: block;
  margin-top: 10px;
  font-weight: 950;
  letter-spacing: -1px;
}

.top-tabs {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}

.tab-btn {
  width: auto;
  min-width: 160px;
  background: var(--card);
  color: var(--text);
}

.tab-btn.active {
  border-color: transparent;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
}

.page { display: none; }
.active-page { display: block; }

.card, .profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card h2, .profile-card h2 {
  margin-top: 0;
  letter-spacing: -.4px;
}

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

.search-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 12px;
  margin-top: 20px;
}

.profile-card {
  display: none;
  text-align: center;
  background:
    linear-gradient(160deg, rgba(255,106,0,.13), rgba(255,176,0,.07)),
    var(--card);
}

.avatar {
  width: 122px;
  height: 122px;
  border-radius: 50%;
  object-fit: cover;
  border: 5px solid var(--primary);
  box-shadow: 0 0 38px rgba(255,106,0,.35);
}

.profile-card h2 {
  font-size: 30px;
  margin: 18px 0 10px;
}

.user-id {
  display: inline-flex;
  gap: 8px;
  background: rgba(255,106,0,.12);
  color: var(--primary);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 900;
  margin-bottom: 22px;
}

.charge-form {
  max-width: 520px;
  margin: 0 auto;
  text-align: left;
  display: grid;
  gap: 11px;
}

body.rtl .charge-form { text-align: right; }

.charge-form label {
  color: var(--muted);
  font-weight: 900;
}

.big-input {
  text-align: center;
  font-size: 34px;
  font-weight: 950;
  padding: 22px;
  border: 2px solid rgba(255,106,0,.28);
}

.big-input.small { font-size: 23px; }

/* TRANSACTIONS */

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.refresh-btn {
  max-width: 160px;
}

.history {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  background: rgba(255,106,0,.055);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 16px;
}

.tx-main b {
  font-size: 17px;
}

.tx-date {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.tx-side {
  text-align: right;
}

body.rtl .tx-side {
  text-align: left;
}

.tx-coins {
  font-size: 20px;
  font-weight: 950;
}

.tx-amount {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.badge {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
  margin-top: 7px;
}

.badge.success {
  background: rgba(22,163,74,.12);
  color: var(--green);
}

.badge.manual_check,
.badge.pending,
.badge.failed {
  background: rgba(255,106,0,.14);
  color: var(--primary);
}

.receipt-link {
  display: block;
  width: auto;
  margin-top: 8px;
  color: var(--primary);
  font-weight: 900;
  text-decoration: none;
  font-size: 13px;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: inherit;
}

.receipt-link:hover {
  text-decoration: underline;
}

/* MODAL / LOADING */

.modal, .loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  z-index: 100;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.loading-overlay {
  z-index: 200;
  color: white;
  text-align: center;
  align-content: center;
  gap: 18px;
}

.loader {
  width: 56px;
  height: 56px;
  border: 5px solid rgba(255,255,255,.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

/* MOBILE */

.bottom-nav { display: none; }

@media (max-width: 720px) {
  .top-tabs { display: none; }

  .app-header {
    width: calc(100% - 28px);
    padding-top: 18px;
  }

  .brand-title h1 {
    font-size: 24px;
  }

  .brand-title p {
    font-size: 13px;
  }

  .main-logo {
    width: 48px;
    height: 48px;
  }

  .settings-menu {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 92px;
    top: auto;
    width: auto;
    padding: 14px;
    border-radius: 26px;
    z-index: 120;
    animation: sheetUp .18s ease-out;
  }

  .content {
    width: calc(100% - 28px);
  }

  .balance-card {
    min-height: 170px;
    border-radius: 30px;
    padding: 28px 18px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

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

  .refresh-btn {
    max-width: none;
  }

  .card,
  .profile-card,
  .balance-card {
    max-width: 100%;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .tx-side {
    text-align: left;
  }

  body.rtl .tx-side {
    text-align: right;
  }

  .bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    z-index: 50;
  }

  .bottom-btn {
    padding: 13px 8px;
    border-radius: 16px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
  }

  .bottom-btn.active {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    border-color: transparent;
  }

  .bottom-btn.danger {
    color: var(--danger);
  }

  .modal-actions {
    flex-direction: column;
  }
}

@keyframes sheetUp {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
