/* Post Trade — стили (mobile-first, без внешних шрифтов и inline-стилей) */

/* ---------- Токены тем ---------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --surface: #1c1c1e;
  --surface-2: #2a2a2d;
  --border: #2f2f33;
  --text: #f2f2f2;
  --muted: #9a9aa0;
  --accent: #2ea6ff;
  --warn: #f5a623;
  --danger: #ff4d4f;
  --success: #4caf50;
  --accent-soft: rgba(46, 166, 255, 0.16);
  --danger-soft: rgba(255, 77, 79, 0.16);
  --success-soft: rgba(76, 175, 80, 0.16);
  --warn-soft: rgba(245, 166, 35, 0.16);
  --overlay: rgba(0, 0, 0, 0.6);
  --toast-bg: #2a2a2d;
  --toast-text: #ffffff;
  --radius: 12px;
  --header-h: 60px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #e3e6ea;
  --text: #111111;
  --muted: #6b7280;
  --accent-soft: rgba(46, 166, 255, 0.14);
  --danger-soft: rgba(255, 77, 79, 0.12);
  --success-soft: rgba(76, 175, 80, 0.14);
  --warn-soft: rgba(245, 166, 35, 0.16);
  --overlay: rgba(17, 17, 17, 0.45);
  --toast-bg: #1c1c1e;
  --toast-text: #ffffff;
}

/* ---------- База ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.modal-open,
body.drawer-open {
  overflow: hidden;
}

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

a {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
  flex-shrink: 0;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warn { color: var(--warn); }
.right { margin-left: auto; }

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------- Заставка ---------- */
.splash {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: #121212;
}

.brand-mark-lg {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.94); }
}

/* ---------- Бренд ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(0.94); }
.btn:disabled { opacity: 0.6; cursor: default; filter: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #111; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 14px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover { background: var(--surface-2); }
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-row .btn { flex: 1 1 120px; }

/* ---------- Поля форм ---------- */
.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder { color: var(--muted); }

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[readonly] { opacity: 0.8; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

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

.span-2 { grid-column: 1 / -1; }

@media (min-width: 520px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 720px) {
  .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(255, 77, 79, 0.35);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
}

.checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  margin: 0;
  flex-shrink: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-size: 15px;
}

.check-list {
  display: flex;
  flex-direction: column;
}

.check-list .check-row { min-height: 44px; }

/* ---------- Переключатель (switch) ---------- */
.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

.switch-input:checked + .switch {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-input:checked + .switch::after { transform: translateX(20px); }
.switch-input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.switch-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 15px;
}

/* ---------- Карточки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.card + .card { margin-top: 12px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px;
}

.empty.small { padding: 16px; }

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 24px 0 12px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 16px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---------- Экран авторизации (следует выбранной теме) ---------- */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--bg);
  color: var(--text);
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-theme {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 5;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.auth-theme:hover { color: var(--text); }

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-logo .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.auth-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.auth-title .t-blue { color: var(--accent); }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.auth-tab.active {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form .btn-primary {
  min-height: 48px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.auth-error {
  background: rgba(255, 77, 79, 0.15);
  color: #ff6b6d;
  border: 1px solid rgba(255, 77, 79, 0.35);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
}

/* ---------- Оболочка приложения ---------- */
.shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--header-h);
  padding: 6px 12px;
}

.header-spacer { flex: 1; }

.hdr-toggles {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hdr-toggle {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
}

.hdr-toggle-label {
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.hdr-toggle .switch {
  width: 38px;
  height: 20px;
}

.hdr-toggle .switch::after {
  width: 14px;
  height: 14px;
}

.hdr-toggle .switch-input:checked + .switch::after { transform: translateX(18px); }

.hdr-user {
  display: none;
  flex-direction: column;
  align-items: flex-end;
  margin: 0 8px;
  min-width: 0;
}

.hdr-email {
  font-size: 14px;
  font-weight: 600;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hdr-role {
  font-size: 12px;
  color: var(--muted);
}

.shell-body {
  display: block;
  flex: 1;
}

.sidebar { display: none; }

.page {
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
  min-width: 0;
}

@media (min-width: 960px) {
  .header-inner { padding: 6px 16px; gap: 10px; }
  .hdr-user { display: flex; }
  .btn-menu { display: none; }

  .shell-body {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
  }

  .sidebar {
    display: block;
    position: sticky;
    top: var(--header-h);
    height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-left: 1px solid var(--border);
  }

  .page { padding: 24px; }
}

/* ---------- Меню ---------- */
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 10px;
  border: 0;
  background: none;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-link:hover { background: var(--surface-2); }

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-link svg { color: inherit; opacity: 0.9; }
.nav-logout { color: var(--danger); }
.nav-logout:hover { background: var(--danger-soft); }

/* ---------- Выезжающее меню (drawer) ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 40;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(85vw, 320px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  visibility: hidden;
}

.drawer.open {
  transform: none;
  visibility: visible;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
}

.drawer-user {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.drawer-user .hdr-email {
  display: block;
  max-width: 100%;
}

@media (min-width: 960px) {
  .drawer,
  .drawer-overlay { display: none; }
}

/* ---------- Главная ---------- */
.balance-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.balance-amount {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.balance-amount .unit {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.balance-addr {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 14px;
  margin-bottom: 14px;
}

.info-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.info-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  border-top: 1px solid var(--border);
}

.info-list svg { color: var(--muted); }

.reward {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.reward-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.reward-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  font-size: 14px;
}

/* ---------- Сделки ---------- */
.deals-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

@media (min-width: 640px) {
  .chips { display: flex; flex-wrap: wrap; }
}

.chip {
  --chip: var(--muted);
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--chip);
  background: transparent;
  color: var(--chip);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chip.active {
  background: var(--chip);
  color: #fff;
}

.chip-accent { --chip: var(--accent); }
.chip-warn { --chip: var(--warn); }
.chip-warn.active { color: #111; }
.chip-danger { --chip: var(--danger); }
.chip-grey { --chip: var(--muted); }

/* ---------- Реквизиты (страница) ---------- */
.req-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.req-tools .btn-primary { margin-left: auto; }

.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.list-tools .select { width: auto; max-width: 100%; }

.table-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Депозит / Поддержка / Настройки ---------- */
.addr-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: 10px 0;
  min-width: 0;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 15px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.settings-section { margin-bottom: 12px; }

/* ---------- Модальное окно ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  outline: none;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.modal-foot .btn { flex: 1 1 120px; }

@media (min-width: 520px) {
  .modal-foot .btn { flex: 0 0 auto; }
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
  z-index: 100;
}

.toast {
  max-width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: none;
}

/* ---------- Прочее ---------- */
.usdt-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.usdt-icon svg {
  width: 40px;
  height: 40px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
