* {
  box-sizing: border-box;
}

:root {
  --tg-theme-bg-color: #1c1c1e;
  --tg-theme-text-color: #000;
  --card-bg: #ffffff;
  --border: #e0e0e0;
  --accent: #3390ec;
  --text-muted: #707579;
  --radius: 12px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #050608;
  color: var(--tg-theme-text-color, #000);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#app {
  position: relative;
  width: 100%;
  max-width: 420px;
  min-height: 400px;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #050608;
  background-blend-mode: soft-light;
}

.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 10%, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.7));
}

.card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  padding: 28px 22px 24px;
  backdrop-filter: blur(22px);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.logo-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #ff6b6b, #ff3b30);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.6);
  border: 4px solid rgba(255, 255, 255, 0.85);
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.logo-img[hidden] {
  display: none;
}

.logo-icon {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.brand {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #000;
}

.step {
  width: 100%;
}

.step.hidden {
  display: none;
}

.subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
  line-height: 1.4;
}

.intro-subtitle {
  text-align: center;
}

.intro-box {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
  margin-bottom: 18px;
}

.intro-text {
  margin: 0;
  font-size: 14px;
  color: #111;
  text-align: center;
}

.intro-confirm-btn {
  margin-top: 4px;
}

.field {
  margin-bottom: 16px;
  width: 100%;
  text-align: left;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
  backdrop-filter: blur(16px);
}

.input-wrap .prefix {
  padding: 12px 12px 12px 14px;
  font-size: 16px;
  color: #000;
  white-space: nowrap;
}

.input,
select.input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: none;
  outline: none;
  background: transparent;
  color: #000;
}

.country-select {
  position: relative;
}

.country-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #000;
  cursor: pointer;
  padding: 12px 14px;
  font-size: 16px;
  text-align: left;
}

.country-trigger .country-flag {
  margin-right: 10px;
  flex-shrink: 0;
}

.country-trigger .country-name {
  flex: 1;
}

.country-trigger .country-chevron {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 8px;
}

.country-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.country-dropdown[hidden] {
  display: none;
}

.country-option {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border: none;
  width: 100%;
  background: #fff;
  color: #000;
  font-size: 15px;
  text-align: left;
}

.country-option:hover {
  background: #f5f5f5;
}

.country-option .country-flag {
  margin-right: 10px;
  flex-shrink: 0;
}

.country-option .country-name {
  flex: 1;
}

.country-option .country-code {
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 8px;
}

.password-field {
  position: relative;
}

.password-field .input {
  padding-right: 48px;
}

.toggle-pwd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  opacity: 0.7;
}

.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #000;
  cursor: pointer;
  width: 100%;
}

.checkbox-wrap input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn.primary {
  background: linear-gradient(90deg, #007aff, #0a84ff);
  color: #fff;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(10, 132, 255, 0.55);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  opacity: 0.9;
}

.links {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link {
  color: var(--accent);
  font-size: 14px;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.phone-display {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.edit-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

.lang-switch {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
}

.lang-switch .link {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0 4px;
}

.lang-sep {
  color: var(--text-muted);
  margin: 0 4px;
}

.error-msg {
  margin-top: 12px;
  color: #c00;
  font-size: 14px;
  text-align: center;
}

.error-msg.hidden {
  display: none;
}

.admin-status {
  margin-top: 12px;
  font-size: 14px;
  text-align: center;
}

.admin-status-ok {
  color: #008000;
}

.admin-status-error {
  color: #c00;
}

.admin-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.bot-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.bot-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #999;
  flex-shrink: 0;
}

.bot-status-dot.running {
  background: #34c759;
}

.bot-status-dot.stopped {
  background: #ff3b30;
}

.bot-status-dot.error {
  background: #ff9500;
}

.bot-status-dot.warning {
  background: #ff9500;
}

.bot-status-dot.loading {
  background: #999;
}

.bot-status-text {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-restart {
  margin-left: auto;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-restart:hover {
  background: var(--accent);
  color: #fff;
}

.btn-restart:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  background: #333;
  color: #fff;
  font-size: 14px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.hidden {
  display: none;
}

.intro-wait {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 34px 0 12px;
}

.intro-wait-box {
  min-width: 180px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  font-size: 15px;
  text-align: center;
  color: #111;
}

.intro-folder-wrap {
  position: relative;
  width: 90px;
  height: 90px;
}

.intro-folder-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 72px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffcf7f, #f5a623);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.35);
}

.intro-folder-icon.large {
  width: 88px;
  height: 64px;
}

.spinner-circle {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.6);
  border-top-color: rgba(0, 0, 0, 0.2);
  animation: spin 1s linear infinite;
}

.spinner-circle.large {
  width: 74px;
  height: 74px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.intro-loading {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0 8px;
}

.intro-loading-card {
  width: 100%;
  border-radius: 18px;
  background: #6f6f73;
  padding: 42px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
