/* unified spinner styles */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.spinner-xl { width: 48px; height: 48px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-loader { display: flex; align-items: center; justify-content: center; padding: 24px; min-height: 220px; }
.screen-loader { position: fixed; top: var(--header-height); left: 0; right: 0; bottom: 0; background: var(--surface, #fff); z-index: 9999; display: none; align-items: center; justify-content: center; opacity: 1; transition: opacity .24s ease; }
.screen-loader.show { display: flex; }
.screen-loader.fade-out { opacity: 0; pointer-events: none; }
/* login card */
.login-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 8px; }
.login-logo { height: 84px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.login-desc { color: #666; font-size: 13px; }
.tg-login-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 0; gap: 16px; }
.login-notify-info {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
  max-width: 320px;
  margin-top: 8px;
}

/* Визуальный редактор кнопок */
.buttons-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 8px;
  max-height: 130px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: max-height 0.2s ease;
}

/* Динамическая высота в зависимости от количества рядов */
.buttons-editor[data-rows="1"] {
  max-height: 100px;
  overflow-y: visible;
}

.buttons-editor[data-rows="2"] {
  max-height: 150px;
  overflow-y: visible;
}

.buttons-editor[data-rows="3"] {
  max-height: 200px;
  overflow-y: visible;
}

.buttons-editor[data-rows="4"],
.buttons-editor[data-rows="5"],
.buttons-editor[data-rows="6"],
.buttons-editor[data-rows="7"],
.buttons-editor[data-rows="8"],
.buttons-editor[data-rows="9"],
.buttons-editor[data-rows="10"] {
  max-height: 250px;
  overflow-y: auto;
}
.buttons-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.buttons-editor-header .editor-btn {
  padding: 4px 10px;
  font-size: 12px;
}
#buttons-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn-row {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px;
  background: #f8fafc;
  border-radius: 8px;
  min-height: 36px;
}
.btn-row-buttons {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}
.btn-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(100, 110, 120, 0.45);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-item:active { cursor: grabbing; }
.btn-item.dragging {
  opacity: 0.8;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.btn-item.drag-over {
  outline: 2px dashed var(--accent);
}
.btn-item-text {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-item-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  padding: 0 2px;
  cursor: pointer;
  line-height: 1;
}
.btn-item-remove:hover { color: #fff; }
.btn-row-add {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-row-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-row-remove {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 16px;
  padding: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.btn-row-remove:hover { opacity: 1; }

.btn-row-drag-handle {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  padding: 4px 2px;
  cursor: grab;
  opacity: 0.6;
  transition: opacity 0.15s ease;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -2px;
}

.btn-row-drag-handle:hover { opacity: 1; }
.btn-row-drag-handle:active { cursor: grabbing; }

.btn-row.drag-over-row {
  background: #e8f4ff;
  outline: 2px dashed var(--accent);
}

.btn-row.dragging-row {
  opacity: 0.5;
}
