/**
 * Простые стили для трейдинг-панели myver.
 * Без фреймворков, акцент на читаемости.
 */

:root {
  --bg: #1a1d24;
  --bg-card: #22262e;
  --border: #2d323c;
  --text: #e6e8ec;
  --text-muted: #8b909a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --profit: #22c55e;
  --loss: #ef4444;
  --input-bg: #181b21;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

h1, h2, h3 {
  margin: 0 0 0.75rem;
  font-weight: 600;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Карточки */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

/* Кнопки */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
}
.btn:hover {
  background: var(--accent-hover);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 13px;
}

.btn-danger {
  background: var(--loss);
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--profit);
}
.btn-success:hover {
  background: #16a34a;
}

/* Формы */
input, select {
  width: 100%;
  max-width: 200px;
  padding: 0.5rem 0.75rem;
  font-size: 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.trade-instrument-display {
  font-weight: 600;
  color: var(--text);
  padding: 0.35rem 0;
}

.sl-tp-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.sl-tp-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  margin-bottom: 0;
}
.sl-tp-mode-option input { width: auto; max-width: none; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}
.form-group {
  margin-bottom: 0.75rem;
}

/* Сетка дашборда */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dashboard-item .value {
  font-size: 1.5rem;
  font-weight: 600;
}

.value.positive { color: var(--profit); }
.value.negative { color: var(--loss); }

/* Таблица сделок */
.table,
.trades-table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td,
.trades-table th,
.trades-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th,
.trades-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
}
.table tr:hover,
.trades-table tr:hover {
  background: rgba(255,255,255,0.03);
}
.table .profit,
.trades-table .pnl.positive { color: var(--profit); }
.table .loss,
.trades-table .pnl.negative { color: var(--loss); }

.trades-table .actions {
  display: flex;
  gap: 0.5rem;
}

/* График */
.chart-wrap {
  height: 360px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* Маржин-колл: пульсация рамки графика (красное свечение внутрь) */
@keyframes margin-pulse {
  0%, 100% {
    border-color: rgba(239, 68, 68, 0.45);
    box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.2), inset 0 0 25px 0 rgba(239, 68, 68, 0.05);
  }
  50% {
    border-color: rgba(239, 68, 68, 0.9);
    box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.45), inset 0 0 35px 0 rgba(239, 68, 68, 0.12);
  }
}

@keyframes margin-pulse-critical {
  0%, 100% {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.3), inset 0 0 35px 0 rgba(239, 68, 68, 0.1);
  }
  50% {
    border-color: rgb(239, 68, 68);
    box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.65), inset 0 0 45px 0 rgba(239, 68, 68, 0.2);
  }
}

.chart-wrap.margin-warning {
  animation: margin-pulse 1.8s ease-in-out infinite;
}

.chart-wrap.margin-critical {
  animation: margin-pulse-critical 1s ease-in-out infinite;
}

.margin-call-msg { margin-bottom: 0.75rem; }
.margin-call-msg.margin-call-critical { font-weight: 600; }

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

/* Сообщения */
.msg {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}
.msg.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}
.msg.success {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

/* Заголовок страницы */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.section {
  margin-bottom: 2rem;
}

.empty {
  color: var(--text-muted);
  padding: 1rem;
  text-align: center;
}

@media (min-width: 768px) {
  .container { padding: 1.5rem; }
  .dashboard-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ========== Кабинет: шапка и навигация ========== */
.cabinet-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.cabinet-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
}
.cabinet-logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}
.cabinet-logo:hover {
  color: var(--accent);
  text-decoration: none;
}
.cabinet-nav {
  display: flex;
  gap: 0.25rem;
}
.cabinet-nav-link {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.cabinet-nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}
.cabinet-nav-link.active {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
}
.cabinet-main {
  min-height: calc(100vh - 56px);
  padding: 1rem 0;
}
.cabinet-content {
  padding-top: 0.5rem;
}

/* ========== МОЙ АККАУНТ: вкладки ========== */
.cabinet-page-title {
  margin-bottom: 1.25rem;
  font-size: 1.5rem;
}
.account-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.account-tab {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.account-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}
.account-tab.active {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
}
.account-panels {
  margin-top: 0;
}
.account-panel {
  display: none;
}
.account-panel.active {
  display: block;
}

/* Информация: список полей */
.section-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}
.account-greeting {
  margin: 0 0 1rem;
  font-size: 1rem;
}
.text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.info-list {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.info-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  align-items: baseline;
}
.info-row dt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.info-row dd {
  margin: 0;
  font-size: 1rem;
}
.info-row .currency {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.account-form .form-group {
  margin-bottom: 1rem;
}
.account-form textarea {
  width: 100%;
  max-width: 100%;
  min-height: 100px;
  padding: 0.5rem 0.75rem;
  font-size: 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
}
.account-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Поддержка: тикет */
.support-form .form-group {
  margin-bottom: 1rem;
}
.support-form textarea {
  width: 100%;
  max-width: 100%;
  min-height: 120px;
  padding: 0.5rem 0.75rem;
  font-size: 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
}
.support-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.support-form select {
  max-width: 100%;
}
.support-instruction {
  margin-bottom: 1rem;
  padding: 1rem;
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
}
.support-instruction-content {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}
.support-attach-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.support-attach-zone:hover {
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
}
.support-attach-zone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.support-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.support-attach-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.support-attach-list {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--accent);
  word-break: break-all;
}

/* Снятие: баланс и способы */
.withdrawal-balance-card {
  margin-bottom: 1rem;
}
.withdrawal-balance {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.withdrawal-balance .value {
  font-size: 1.5rem;
  font-weight: 600;
}
.withdrawal-methods {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.withdrawal-method-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.withdrawal-method-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.withdrawal-method-btn.active {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--accent);
}
.withdrawal-panel {
  display: none;
}
.withdrawal-panel.active {
  display: block;
}

/* Документы: зоны загрузки */
.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.document-upload-card {
  margin-bottom: 0;
}
.document-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover {
  border-color: var(--text-muted);
  background: rgba(255,255,255,0.02);
}
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.upload-filename {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--accent);
  word-break: break-all;
}

/* История пополнений/снятий */
.table-responsive {
  overflow-x: auto;
  margin-top: 0.5rem;
}
.history-table {
  min-width: 700px;
}
.history-type-deposit {
  color: var(--profit);
  font-weight: 500;
}
.history-type-withdrawal {
  color: var(--loss);
  font-weight: 500;
}
.history-status-confirmed {
  color: var(--profit);
  font-size: 0.9rem;
}
.history-status-pending {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Модальное окно: по умолчанию скрыто; показ только по классу .modal-wrap.is-open */
.modal-wrap {
  display: none !important;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-wrap.is-open {
  display: flex !important;
}

@media (min-width: 768px) {
  .info-row { grid-template-columns: 200px 1fr; }
}

/* ——— Auth (login, register) ——— */
.auth-page .cabinet-main { padding: 2rem 1rem; }
.auth-main { max-width: 420px; margin: 0 auto; }
.auth-card { padding: 1.5rem 1.75rem; }
.auth-title { margin-bottom: 1.25rem; font-size: 1.35rem; }
.auth-form .form-group { margin-bottom: 1rem; }
.auth-form .auth-input { max-width: 100%; }
.auth-remember { margin-bottom: 1rem; }
.auth-checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; color: var(--text); font-size: 14px; }
.auth-checkbox-label input { width: auto; max-width: none; }
.auth-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.25rem; }
.auth-link { font-size: 0.9rem; }
.auth-footer { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.9rem; }
.auth-text { color: var(--text-muted); margin-bottom: 1rem; font-size: 0.95rem; }
.auth-alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.auth-alert-success { background: rgba(34, 197, 94, 0.15); color: var(--profit); border: 1px solid rgba(34, 197, 94, 0.3); }
.auth-alert-error { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.auth-errors { margin: 0; padding-left: 1.25rem; }
.auth-error { display: block; font-size: 0.85rem; color: #fca5a5; margin-top: 0.25rem; }
.auth-hint { display: block; font-size: 0.8rem; color: #9ca3af; margin-top: 0.2rem; }
.required { color: var(--loss); }

/* Кнопка «Выйти» в шапке кабинета */
.cabinet-nav-form { display: inline; margin: 0; padding: 0; }
.cabinet-btn-logout { background: none; border: none; cursor: pointer; font: inherit; color: inherit; padding: 0; margin: 0; }
.cabinet-btn-logout:hover { text-decoration: underline; }
.cabinet-nav .cabinet-nav-form .cabinet-btn-logout { padding: 0.5rem 0; }

/* Поддержка: список тикетов и переписка */
.support-ticket-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.support-ticket-status { font-size: 0.85rem; padding: 0.2rem 0.5rem; border-radius: 4px; }
.support-ticket-status--open { background: rgba(34, 197, 94, 0.2); color: var(--profit); }
.support-ticket-status--closed { background: var(--border); color: var(--text-muted); }
.support-messages { margin-bottom: 1.5rem; }
.support-message { margin-bottom: 1rem; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--border); }
.support-message--user { background: rgba(59, 130, 246, 0.08); }
.support-message--admin { background: var(--input-bg); }
.support-message-meta { font-size: 0.85rem; color: var(--text-muted); display: block; margin-bottom: 0.25rem; }
.support-message-body { white-space: pre-wrap; word-break: break-word; }
.support-reply-form { margin-top: 1rem; }
.support-close-form { margin-top: 0.5rem; }
.support-back { margin-top: 1rem; }
.support-ticket-list { list-style: none; padding: 0; margin: 0; }
.support-ticket-list li { margin-bottom: 0.5rem; }
.support-ticket-link { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.support-ticket-date { font-size: 0.85rem; color: var(--text-muted); margin-left: auto; }
