/* ═══════════════════════════════════════════════════════════════
   СТИЛЬ В ДУХЕ РЕФЕРЕНСА (ТЁМНАЯ ТЕМА)
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg:        #0a0e1a;
  --bg-soft:   #0f1424;
  --card:      #171d2e;
  --card-2:    #1c2338;
  --card-hi:   #212a44;
  --border:    rgba(255,255,255,0.06);
  --border-2:  rgba(255,255,255,0.10);
  --text:      #eef2f9;
  --text-dim:  #8b95a8;
  --text-soft: #a8b2c5;
  --accent:    #4a7dff;
  --accent-2:  #6b95ff;
  --accent-bg: linear-gradient(135deg,#4a7dff 0%,#2f5ce0 100%);
  --gold:      #ffc83c;
  --gold-2:    #ffdb70;
  --danger:    #ff5c5c;
  --success:   #4ad06a;
  --radius:    20px;
  --radius-sm: 14px;
  --radius-lg: 24px;
  --shadow:    0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4;
  overscroll-behavior: none;
  touch-action: pan-y;
  min-height: 100vh;
}

#app {
  padding: 20px 16px;
  padding-top: calc(70px + env(safe-area-inset-top));
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── ЗАГОЛОВКИ ─── */
h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 20px;
  letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 12px;
}
h1 .ic { width: 26px; height: 26px; }

h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 12px;
  letter-spacing: -0.3px;
}

/* ─── КАРТОЧКИ ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, background 0.15s;
  cursor: pointer;
}
.card:active { transform: scale(0.985); background: var(--card-2); }
.card.no-click { cursor: default; }
.card.no-click:active { transform: none; background: var(--card); }

.card.ok  { border-color: rgba(74,208,106,0.4); }
.card.err { border-color: rgba(255,92,92,0.4); }

/* Карточка-акцент (синяя, как "Project A") */
.card.accent {
  background: var(--accent-bg);
  border: none;
  color: white;
}
.card.accent .label { color: rgba(255,255,255,0.75); }
.card.accent .val { color: white; }
.card.accent .sub { color: rgba(255,255,255,0.8); }

/* ─── РЯДЫ ─── */
.row {
  display: flex; justify-content: space-between;
  align-items: center; gap: 10px;
}
.flex { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── ТЕКСТОВЫЕ БЛОКИ ─── */
.label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.val {
  color: var(--text);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
}
.sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, monospace; color: var(--text-soft); font-size: 13px; }

.tag {
  background: rgba(74,125,255,0.15);
  color: var(--accent-2);
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

.hint {
  color: var(--text-soft);
  font-size: 13px;
  margin: 8px 0 16px;
  line-height: 1.5;
}

/* ─── СЕТКА 2 КОЛОНКИ ─── */
.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 12px;
}

/* ─── КНОПКИ ─── */
button {
  background: var(--accent-bg);
  color: white;
  border: none;
  padding: 15px 20px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 15px;
  width: 100%;
  margin-top: 10px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(74,125,255,0.25);
}
button:active { opacity: 0.85; transform: scale(0.98); }
button .ic, button .ic-black { width: 18px; height: 18px; filter: brightness(0) invert(1); }

button.secondary {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  box-shadow: none;
}
button.secondary .ic, button.secondary .ic-black { filter: none; }

button.danger {
  background: linear-gradient(135deg,#ff5c5c 0%,#d63c3c 100%);
  box-shadow: 0 4px 14px rgba(255,92,92,0.25);
}

button.small {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  margin: 0;
  border-radius: 10px;
  box-shadow: none;
}
button.small.danger { background: rgba(255,92,92,0.15); color: #ff8888; }

/* Пункт меню в списке (как строки задач) */
button.menu-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  justify-content: flex-start;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 15px;
}
button.menu-btn:active { background: var(--card-2); }
button.menu-btn img { margin-right: 4px; }

button.chip {
  width: auto;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--text-soft);
  border: 1px solid var(--border-2);
  box-shadow: none;
}
button.chip:active { background: var(--card-hi); }

.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 8px 0;
}

/* ─── ПОЛЯ ВВОДА ─── */
.token-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border-2);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  margin-top: 6px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.token-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}
.token-input::placeholder { color: var(--text-dim); }
textarea.token-input { resize: vertical; min-height: 80px; }

select.token-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%238b95a8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px;
  padding-right: 40px;
}

/* ─── СПИСКИ ЮЗЕРОВ ─── */
.user-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.user-row:last-child { border-bottom: none; }
.user-row .name { flex: 1; color: var(--text); font-size: 15px; font-weight: 500; }
.user-row .size { color: var(--accent-2); font-weight: 700; font-size: 14px; }

.del-btn {
  background: rgba(255,92,92,0.15);
  color: #ff8888;
  border: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  padding: 0; margin: 0;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: none;
}

.actions-row {
  display: flex; gap: 8px;
  margin-top: 12px;
}
.actions-row button { flex: none; }

/* ─── БЕЙДЖИ ─── */
.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 14px;
}
.badge.gold { background: rgba(255,200,60,0.15); color: var(--gold); }
.badge.green { background: rgba(74,208,106,0.15); color: var(--success); }
.badge.gray { background: rgba(255,255,255,0.06); color: var(--text-dim); }

/* ─── ЗАГРУЗКА ─── */
.loading {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: 15px;
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}

/* ─── СКЕЛЕТОНЫ ─── */
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hi) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
  height: 88px;
  margin-bottom: 10px;
}

/* ─── ЧАТ AI ─── */
#chatLog {
  background: var(--bg-soft) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 14px !important;
}

/* ─── ФИКС ДЛЯ СТАРЫХ ИНЛАЙНОВ ─── */
.card[style*="background:#0e1830"] { background: var(--card) !important; border-color: var(--border) !important; }


/* ═══════════════════════════════════════════════════════════════
   ДАШБОРД — сетка карточек и мини-стата
   ═══════════════════════════════════════════════════════════════ */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.dash-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.dash-stat-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.dash-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 22px 0 12px;
  padding-left: 4px;
}

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

.dash-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
  box-shadow: var(--shadow);
  min-height: 90px;
  position: relative;
  overflow: hidden;
}
.dash-tile:active { transform: scale(0.97); background: var(--card-2); }

.dash-tile-ic {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.dash-tile-t {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

/* Цвета плиток */
.dash-tile.blue   { border-color: rgba(74,125,255,0.35); }
.dash-tile.blue   .dash-tile-ic { background: linear-gradient(135deg,#4a7dff,#2f5ce0); }
.dash-tile.gold   { border-color: rgba(255,200,60,0.35); }
.dash-tile.gold   .dash-tile-ic { background: linear-gradient(135deg,#ffc83c,#e5a52e); }
.dash-tile.purple { border-color: rgba(160,100,255,0.35); }
.dash-tile.purple .dash-tile-ic { background: linear-gradient(135deg,#a064ff,#7030d0); }
.dash-tile.pink   { border-color: rgba(255,100,180,0.35); }
.dash-tile.pink   .dash-tile-ic { background: linear-gradient(135deg,#ff64b4,#d03080); }
.dash-tile.green  { border-color: rgba(74,208,106,0.35); }
.dash-tile.green  .dash-tile-ic { background: linear-gradient(135deg,#4ad06a,#30a850); }
.dash-tile.orange { border-color: rgba(255,140,60,0.35); }
.dash-tile.orange .dash-tile-ic { background: linear-gradient(135deg,#ff8c3c,#e06020); }
.dash-tile.dark   { background: var(--card-2); }
.dash-tile.dark   .dash-tile-ic { background: rgba(255,255,255,0.06); }

/* Обрезка старых menu-btn если остались */
button.menu-btn {
  min-height: auto;
}


/* ═══════════════════════════════════════════════════════════════
   СПИСОК ЧАТОВ
   ═══════════════════════════════════════════════════════════════ */
.chats-list { display: flex; flex-direction: column; gap: 8px; }

.chat-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
  box-shadow: var(--shadow);
}
.chat-item:active { transform: scale(0.985); background: var(--card-2); }

.chat-item-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(74,125,255,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.chat-item-body {
  flex: 1; min-width: 0;
}

.chat-item-title {
  font-size: 15px; font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.chat-item-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.chat-item-val {
  font-size: 20px; font-weight: 800;
  color: var(--accent-2);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}
.chat-item-val-unit {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  margin-left: 2px;
}

/* Убираем старые стили */
.user-row { display: none; }
