/* Regrid — панель управления. Оформление: тёмная терминальная тема. */

:root {
  --bg-0: #060912;
  --bg-1: #0a101d;
  --panel: rgba(17, 25, 42, .88);
  --panel-solid: #111a2b;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #e9f0fb;
  --muted: #8da0bf;
  --faint: #5f708c;
  --accent: #5b8cff;
  --accent-2: #23d3ee;
  --good: #25ca92;
  --bad: #ff5f6d;
  --warn: #ffb020;
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg-0);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Фон: статичный градиент на отдельном слое.
   Никакой анимации — она вместе с размытием заставляла браузер
   перерисовывать весь экран на каждом кадре. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(42% 42% at 12% 8%, rgba(91, 140, 255, .22), transparent 60%),
    radial-gradient(46% 46% at 88% 4%, rgba(35, 211, 238, .16), transparent 62%),
    radial-gradient(50% 50% at 70% 92%, rgba(37, 202, 146, .12), transparent 64%),
    var(--bg-0);
}

/* ---------- Каркас: меню слева, рабочая область справа ---------- */

.shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  background: #0a0f1c;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 650;
  letter-spacing: .2px;
  padding: 2px 8px 0;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px -10px rgba(91, 140, 255, .9);
}
.brand .mark svg { width: 17px; height: 17px; }
.brand .name { font-size: 15px; }
.brand .sub { color: var(--faint); font-size: 12px; font-weight: 500; letter-spacing: .3px; }

/* Нижний блок меню: окружение и аварийная остановка. */
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 4px;
}
.side-foot .badge { justify-content: center; }
.side-foot #kill { width: 100%; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .2px;
  background: rgba(255, 255, 255, .03);
}
.badge::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}
.badge.test { color: var(--good); border-color: rgba(37, 202, 146, .35); }
.badge.live { color: var(--bad); border-color: rgba(255, 95, 109, .45); background: rgba(255, 95, 109, .09); }

/* ---------- Навигация (вертикальный список в левой колонке) ---------- */

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar nav button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: color .2s var(--ease), background .2s var(--ease);
}
/* Активный раздел помечаем полоской слева — так принято в биржевых терминалах. */
.sidebar nav button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  transform: translateY(-50%) scaleY(0);
  transition: transform .22s var(--ease);
}
.sidebar nav button svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .85; }
.sidebar nav button span { overflow: hidden; text-overflow: ellipsis; }
.sidebar nav button:hover { color: var(--text); background: rgba(255, 255, 255, .045); transform: none; }
.sidebar nav button.active { color: var(--text); background: linear-gradient(90deg, rgba(91, 140, 255, .2), rgba(91, 140, 255, .05)); }
.sidebar nav button.active::before { transform: translateY(-50%) scaleY(1); }
.sidebar nav button.active svg { opacity: 1; color: var(--accent-2); }

/* ---------- Рабочая область ---------- */

main { padding: 22px 26px 44px; max-width: 1360px; }

.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: .2px; }

.tab { display: none; }
/* Появление вкладки — только прозрачность: без сдвигов и размытий. */
.tab.active { display: block; animation: tabIn .22s ease-out both; }

@keyframes tabIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .18), transparent);
}

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

h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 9px;
}
h2::before {
  content: "";
  width: 3px; height: 15px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.hint { color: var(--muted); font-size: 13px; margin: -4px 0 14px; }
.note { color: var(--muted); font-size: 13px; margin-top: 12px; }
.note:empty { display: none; }
.caption { color: var(--faint); font-size: 12px; margin-top: 8px; }

.hidden { display: none; }

/* ---------- Формы ---------- */

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  background: rgba(6, 10, 20, .75);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  min-width: 116px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(91, 140, 255, .65);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, .16);
  background: rgba(9, 14, 26, .9);
}
select { cursor: pointer; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 13px;
  margin-bottom: 16px;
}
.grid-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .2px;
}
.grid-form input, .grid-form select { width: 100%; }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { min-width: 0; width: 15px; height: 15px; accent-color: var(--accent); }

/* ---------- Кнопки ---------- */

button {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #6b97ff, #4f7dff);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 17px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .25s var(--ease);
  box-shadow: 0 10px 22px -14px rgba(91, 140, 255, .95);
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0) scale(.985); }
button:disabled { opacity: .55; cursor: default; transform: none; }

button.small { padding: 5px 11px; font-size: 12px; box-shadow: none; }
button.ghost {
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
button.ghost:hover { background: rgba(255, 255, 255, .08); }
button.danger {
  background: linear-gradient(180deg, #ff6b78, #f0464f);
  box-shadow: 0 10px 22px -14px rgba(255, 95, 109, .95);
}
#kill { letter-spacing: .6px; font-weight: 650; }

/* ---------- Карточки показателей ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .012));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  overflow: hidden;
  transition: transform .28s var(--ease), border-color .28s var(--ease);
}
/* Появление карточек задаётся из app.js — один раз на контейнер. */

.card::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: .5;
  transition: opacity .28s var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.card:hover::after { opacity: 1; }

.card .label { color: var(--muted); font-size: 12px; letter-spacing: .2px; }
.card .value {
  font-size: 23px;
  font-weight: 650;
  margin-top: 7px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
}
.card .value.good { color: var(--good); }
.card .value.bad { color: var(--bad); }

/* ---------- База знаний: витрина импортированных монет ---------- */

.wide { flex: 1 1 380px; min-width: 220px; }

.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(214px, 1fr));
  gap: 13px;
}

/* Карточка монеты — кнопка, поэтому перекрываем базовые стили button. */
.kb-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 14px 15px;
  text-align: left;
  font-weight: 400;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .012));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
  transition: transform .26s var(--ease), border-color .26s var(--ease), background .26s var(--ease);
}
.kb-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  background: linear-gradient(180deg, rgba(91, 140, 255, .13), rgba(255, 255, 255, .015));
}
.kb-card:active { transform: translateY(-1px) scale(.995); }

.kb-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.kb-sym { font-size: 14px; font-weight: 650; letter-spacing: .3px; }
.kb-name {
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.kb-price .good, .kb-price .bad { font-size: 12px; font-weight: 600; }

.kb-card .spark { width: 100%; height: 42px; display: block; opacity: .95; }

.kb-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 11.5px;
}
.kb-meta .pill { padding: 2px 8px; font-size: 10.5px; }

.kb-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(164px, 1fr));
  gap: 11px;
  margin-bottom: 4px;
}
.kb-stat {
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.kb-stat .label { color: var(--muted); font-size: 11.5px; letter-spacing: .2px; }
.kb-stat .value {
  margin-top: 5px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Развёрнутый график монеты выше обычного .chart */
#kb-chart svg { height: 260px; }

/* ---------- Таблицы ---------- */

.table { overflow-x: auto; border-radius: var(--radius-sm); }
.table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table th {
  color: var(--faint);
  font-weight: 550;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  position: sticky;
  top: 0;
  background: #0d1524;
  z-index: 2;
}
/* Появление строк задаётся из app.js — только при первой отрисовке,
   чтобы обновление данных не перезапускало анимацию. */
.table tbody tr { transition: background .2s var(--ease); }
.table tbody tr:hover { background: rgba(91, 140, 255, .07); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td { font-variant-numeric: tabular-nums; }
.table th:nth-child(1), .table td:nth-child(1) { padding-left: 14px; }

.empty {
  color: var(--faint);
  padding: 18px 4px;
  font-size: 13px;
}

/* ---------- Метки ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--muted);
  letter-spacing: .2px;
}
.pill.range { color: var(--good); border-color: rgba(37, 202, 146, .4); background: rgba(37, 202, 146, .08); }
.pill.trend { color: var(--bad); border-color: rgba(255, 95, 109, .4); background: rgba(255, 95, 109, .08); }
.pill.warn  { color: var(--warn); border-color: rgba(255, 176, 32, .4); background: rgba(255, 176, 32, .08); }

.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

/* ---------- График ---------- */

.chart { margin-top: 16px; }
.chart svg { width: 100%; height: 190px; display: block; }
.chart .note { display: flex; justify-content: space-between; }

/* ---------- Живые цены ---------- */

.price { display: inline-block; padding: 2px 7px; border-radius: 6px; }
.price-up { animation: flashUp .9s var(--ease); }
.price-down { animation: flashDown .9s var(--ease); }

@keyframes flashUp {
  0% { background: rgba(37, 202, 146, .3); }
  100% { background: transparent; }
}
@keyframes flashDown {
  0% { background: rgba(255, 95, 109, .3); }
  100% { background: transparent; }
}

/* ---------- Уведомления ---------- */

#toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: rgba(17, 26, 43, .95);
  border: 1px solid var(--line);
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .95);
  animation: toastIn .42s var(--ease) both;
  font-size: 13px;
}
.toast.out { animation: toastOut .3s var(--ease) both; }
.toast .dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 5px; flex: 0 0 auto;
  background: var(--accent);
}
.toast.ok .dot { background: var(--good); }
.toast.err .dot { background: var(--bad); }
.toast.warn .dot { background: var(--warn); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(26px) scale(.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(26px) scale(.96); }
}

/* ---------- Модальное окно ---------- */

#modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  background: rgba(3, 6, 12, .78);
  animation: fadeIn .2s ease-out both;
}
#modal.closing { animation: fadeOut .18s ease-out both; }

.modal-card {
  width: min(420px, calc(100vw - 40px));
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 24px 48px -24px #000;
  animation: popIn .2s ease-out both;
}
.modal-card h3 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Полоса прогресса ---------- */

.bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
  min-width: 90px;
}
.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .6s var(--ease);
}

/* ---------- Скроллбар ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .2); background-clip: padding-box; }

/* ---------- Адаптив ---------- */

@media (max-width: 980px) {
  /* Узкий экран: меню переезжает наверх и прокручивается по горизонтали. */
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .sidebar .brand { padding: 0; }
  .sidebar nav {
    flex-direction: row;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav button { width: auto; flex: 0 0 auto; padding: 8px 12px; }
  .sidebar nav button::before { display: none; }
  .side-foot { margin-top: 0; flex-direction: row; align-items: center; padding: 0; }
  main { padding: 16px; }
  .card .value { font-size: 20px; }
  #toasts { left: 16px; right: 16px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- Вход в панель ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 372px;
  padding: 30px 28px 24px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px -34px rgba(0, 0, 0, .95);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.auth-brand .mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px -12px rgba(91, 140, 255, .95);
}
.auth-brand .mark svg { width: 21px; height: 21px; }
.auth-brand .name { font-size: 16px; font-weight: 650; }
.auth-brand .sub { color: var(--faint); font-size: 12px; }

.auth h2 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.2px; }

.auth label {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .2px;
}

.auth .pass { position: relative; display: block; margin-top: 7px; }
.auth .pass input { width: 100%; padding-right: 46px; }
.auth .pass .eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--faint);
}
.auth .pass .eye:hover { transform: translateY(-50%); background: rgba(255, 255, 255, .07); color: var(--text); }
.auth .pass .eye svg { width: 17px; height: 17px; }

.auth button[type="submit"] { width: 100%; margin-top: 4px; }

.auth-error {
  min-height: 19px;
  margin-top: 12px;
  color: var(--bad);
  font-size: 13px;
  text-align: center;
}

